Files
maven-plugins/eclipse/src/plugin-test/maven.xml
2004-10-19 14:13:04 +00:00

174 lines
8.2 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: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-maven-eclipse-addResources">
</goal>
<goal name="test-init">
<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"/>
<x:set var="countCactus" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/cactus/jars/cactus-13-1.6.1.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')])"/>
<assert:assertEquals expected="4" 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.3.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[contains(@path,'src/main')])"/>
<assert:assertEquals expected="1" value="${countUniqueSrc.intValue().toString()}" msg="Src 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-maven-eclipse-addResources">
<attainGoal name="test-init"/>
<!-- Not working! ARgh-->
<j:set var="maven.eclipse.addResources" value="true"/>
<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')])"/>
<assert:assertEquals expected="4" value="${count.intValue().toString()}" msg="Wrong number of generated src directories found"/>
</goal>
</project>