2006-08-20 10:56:00 +00:00

223 lines
11 KiB
XML

<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<project xmlns:j="jelly:core"
xmlns:assert="assert"
xmlns:u="jelly:util"
xmlns:maven="jelly:maven"
xmlns:x="jelly:xml">
<goal name="testPlugin" prereqs="test-eclipse,test-natures,test-builders,test-natures-and-builders,test-classpath-has-generated-source,test-classpath-has-overridden-jar,test-noduplicates,test-classpath-con-entry,test-classpath-no-resources,MPECLIPSE-96,MPECLIPSE-92">
</goal>
<goal name="test-init" prereqs="clean">
<j:set var="dotProject" value="${basedir}/.project"/>
<j:set var="dotClasspath" value="${basedir}/.classpath"/>
<attainGoal name="eclipse:clean"/>
</goal>
<goal name="test-eclipse">
<attainGoal name="test-init"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotProject}" />
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="countJUnit" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/junit/jars/junit-3.8.1.jar')])"/>
<assert:assertEquals expected="1" value="${countJUnit.intValue().toString()}" msg="JUnit dependency not found"/>
<echo>Warning, expecting cactus version 13.1-7 from current cactus plugin</echo>
<x:set var="countCactus" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/cactus/jars/cactus-13-1.7.jar')])"/>
<assert:assertEquals expected="1" value="${countCactus.intValue().toString()}" msg="Only one Cactus dependency should be found"/>
</goal>
<goal name="test-natures">
<attainGoal name="test-init"/>
<j:set var="maven.eclipse.projectnatures" value="n1,a.b.c.n2"/>
<attainGoal name="eclipse:generate-project"/>
<assert:assertFileExists file="${dotProject}" />
<u:file var="projectFile" name="${dotProject}"/>
<x:parse var="projectDoc" xml="${projectFile.toURL()}" />
<x:set var="natures" select="$projectDoc/projectDescription/natures/nature"/>
<assert:assertEquals expected="n1" value="${natures[1].text}" msg="n1 is not the second nature"/>
<assert:assertEquals expected="a.b.c.n2" value="${natures[2].text}" msg="a.b.c.n2 is not the third nature"/>
</goal>
<goal name="test-builders">
<attainGoal name="test-init"/>
<j:set var="maven.eclipse.buildcommands" value="c1,c2,c3"/>
<attainGoal name="eclipse:generate-project"/>
<assert:assertFileExists file="${dotProject}" />
<u:file var="projectFile" name="${dotProject}"/>
<x:parse var="projectDoc" xml="${projectFile.toURL()}" />
<x:set var="builders" select="$projectDoc/projectDescription/buildSpec/buildCommand/name"/>
<assert:assertEquals expected="c1" value="${builders[1].text}" msg="c1 is not the second build command name"/>
<assert:assertEquals expected="c2" value="${builders[2].text}" msg="c2 is not the third build command name"/>
<assert:assertEquals expected="c3" value="${builders[3].text}" msg="c3 is not the fourth build command name"/>
</goal>
<goal name="test-natures-and-builders">
<attainGoal name="test-init"/>
<j:set var="maven.eclipse.projectnatures" value="n7,n9,n11"/>
<j:set var="maven.eclipse.buildcommands" value="c11,c21,c31"/>
<attainGoal name="eclipse:generate-project"/>
<assert:assertFileExists file="${dotProject}" />
<u:file var="projectFile" name="${dotProject}"/>
<x:parse var="projectDoc" xml="${projectFile.toURL()}" />
<x:set var="natures" select="$projectDoc/projectDescription/natures/nature"/>
<x:set var="builders" select="$projectDoc/projectDescription/buildSpec/buildCommand/name"/>
<!-- check natures -->
<assert:assertEquals expected="n7" value="${natures[1].text}" msg="n7 is not the second nature"/>
<assert:assertEquals expected="n9" value="${natures[2].text}" msg="n9 is not the second nature"/>
<assert:assertEquals expected="n11" value="${natures[3].text}" msg="n11 is not the second nature"/>
<!-- check builders -->
<assert:assertEquals expected="c11" value="${builders[1].text}" msg="c11 is not the second build command name"/>
<assert:assertEquals expected="c21" value="${builders[2].text}" msg="c21 is not the second build command name"/>
<assert:assertEquals expected="c31" value="${builders[3].text}" msg="c31 is not the second build command name"/>
</goal>
<goal name="test-classpath-has-generated-source">
<attainGoal name="test-init"/>
<mkdir dir="${maven.gen.src}/gensrc1"/>
<mkdir dir="${maven.gen.src}/gensrc2"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotProject}" />
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@kind,'src')])"/>
<j:set var="expectedDirs" value="6"/>
<j:set var="cactusStatus" value="NOT installed"/>
<maven:get plugin="cactus-maven" property="plugin" var="cactusPlugin" />
<j:if test="${! empty(cactusPlugin)}">
<j:set var="expectedDirs" value="${expectedDirs+1}"/>
<!-- I wish someday I will understand why Jelly requires hacks like
the following ... -->
<j:set var="expectedDirs" value="${expectedDirs.intValue().toString()}"/>
<j:set var="cactusStatus" value="installed"/>
</j:if>
<echo>Cactus plugin ${cactusStatus} - expecting ${expectedDirs} source entries.</echo>
<assert:assertEquals expected="${expectedDirs}" value="${count.intValue().toString()}" msg="Wrong number of generated src directories found"/>
</goal>
<goal name="test-classpath-has-overridden-jar">
<attainGoal name="test-init"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/maven/jars/maven.jar')])"/>
<assert:assertEquals expected="1" value="${count.intValue().toString()}" msg="override by jar tag not found"/>
<x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/commons-logging/jars/commons-logging-1.0.4.jar')])"/>
<assert:assertEquals expected="1" value="${count.intValue().toString()}" msg="maven.jar.override didn't work"/>
</goal>
<goal name="test-noduplicates">
<attainGoal name="test-init"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="countUniqueSrc" select="count($classpathDoc/classpath/classpathentry[ends-with(@path,'src/main')])"/>
<assert:assertEquals expected="1" value="${countUniqueSrc.intValue().toString()}" msg="Src directory should be added only once"/>
<x:set var="countUniqueSrcTest" select="count($classpathDoc/classpath/classpathentry[ends-with(@path,'src/test')])"/>
<assert:assertEquals expected="1" value="${countUniqueSrcTest.intValue().toString()}" msg="Test directory should be added only once"/>
</goal>
<goal name="test-classpath-con-entry">
<attainGoal name="test-init"/>
<j:set var="maven.eclipse.conclasspath" value="org.eclipse.pde.core.requiredPlugins"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="countConEntries" select="count($classpathDoc/classpath/classpathentry[contains(@kind,'con')])"/>
<assert:assertEquals expected="2" value="${countConEntries.intValue().toString()}" msg="Classpath entry kind='con' should be added twice, once mandatory, other variable"/>
</goal>
<goal name="test-classpath-no-resources">
<attainGoal name="test-init"/>
<j:set var="maven.eclipse.resources.addtoclasspath" value="false"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotProject}" />
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@path,'src/resources')])"/>
<assert:assertEquals expected="0" value="${count.intValue().toString()}" msg="The src/resources dir should not be imported"/>
<x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@path,'src/test-resources')])"/>
<assert:assertEquals expected="0" value="${count.intValue().toString()}" msg="The src/test-resources dir should not be imported"/>
</goal>
<goal name="MPECLIPSE-96">
<attainGoal name="test-init"/>
<j:set var="maven.eclipse.resources.addtoclasspath" value="true"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="including" select="$classpathDoc/classpath/classpathentry[contains(@path,'src/resources')]/@including"/>
<x:set var="excluding" select="$classpathDoc/classpath/classpathentry[contains(@path,'src/resources')]/@excluding"/>
<assert:assertEquals expected="**/*.properties|**/*.xml" value="${including[0].value}" msg="Including is not set correctly"/>
<assert:assertEquals expected="**/*.log|**/*.txt" value="${excluding[0].value}" msg="Excluding is not set correctly"/>
</goal>
<goal name="MPECLIPSE-92">
<attainGoal name="test-init"/>
<j:set var="maven.eclipse.output.dir" value="web-content/WEB-INF/classes"/>
<attainGoal name="eclipse"/>
<assert:assertFileExists file="${dotClasspath}" />
<u:file var="classpathFile" name="${dotClasspath}"/>
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
<x:set var="path" select="$classpathDoc/classpath/classpathentry[@kind = 'output']/@path"/>
<assert:assertEquals expected="web-content/WEB-INF/classes" value="${path[0].value}" msg="Output path not set correctly"/>
</goal>
</project>