Author: pgier Date: Fri May 1 14:53:18 2009 New Revision: 770703 URL: http://svn.apache.org/viewvc?rev=770703&view=rev Log: [MANTTASKS-35] Add tests for profiles.
Added: maven/ant-tasks/trunk/src/test/pom-with-profiles.xml (with props) Modified: maven/ant-tasks/trunk/sample.build.xml maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java Modified: maven/ant-tasks/trunk/sample.build.xml URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/sample.build.xml?rev=770703&r1=770702&r2=770703&view=diff ============================================================================== --- maven/ant-tasks/trunk/sample.build.xml (original) +++ maven/ant-tasks/trunk/sample.build.xml Fri May 1 14:53:18 2009 @@ -53,7 +53,7 @@ </target> <target name="test-all-deps" description="All dependencies tests" - depends="test-pom,test-pom-with-parent,test-no-deps,test-pom-deps,test-deps-two-repos,test-deps,test-legacy-pom,test-deps-mirror,test-deps-order,test-deps-sources,test-deps-sources-empty,test-deps-profile"> + depends="test-pom, test-pom-profiles, test-pom-with-parent,test-no-deps,test-pom-deps,test-deps-two-repos,test-deps,test-legacy-pom,test-deps-mirror,test-deps-order,test-deps-sources,test-deps-sources-empty,test-deps-profile"> <echo>test-bad-dep and test-invalid-pom-ref must be run manually, since they are intended to fail</echo> </target> @@ -107,6 +107,59 @@ </fail> </target> + <target name="test-pom-profiles" depends="initTaskDefs"> + + <!-- Test default profile activation --> + <artifact:pom file="src/test/pom-with-profiles.xml" id="project.default"/> + + <echo>Current profile = ${project.default.build.finalName}</echo> + + <fail message="failed to activate profile default"> + <condition> + <not><equals arg1="${project.default.build.finalName}" arg2="default"/></not> + </condition> + </fail> + + <!-- Test explicit profile activation --> + <artifact:pom file="src/test/pom-with-profiles.xml" id="project.myprofile1" > + <profile id="myprofile1"/> + </artifact:pom> + + <echo>Current profile = ${project.myprofile1.build.finalName}</echo> + + <fail message="failed to activate profile myprofile1"> + <condition> + <not><equals arg1="${project.myprofile1.build.finalName}" arg2="myprofile1"/></not> + </condition> + </fail> + + <!-- Test explicit profile activation with "active" attr set --> + <artifact:pom file="src/test/pom-with-profiles.xml" id="project.myprofile2" > + <profile id="myprofile2" active="true"/> + </artifact:pom> + + <echo>Current profile = ${project.myprofile2.build.finalName}</echo> + + <fail message="failed to activate profile myprofile2"> + <condition> + <not><equals arg1="${project.myprofile2.build.finalName}" arg2="myprofile2"/></not> + </condition> + </fail> + + <!-- Test explicit profile deactivation --> + <artifact:pom file="src/test/pom-with-profiles.xml" id="project.noprofile" > + <profile id="default" active="false" /> + </artifact:pom> + + <echo>Current profile = ${project.noprofile.build.finalName}</echo> + + <fail message="failed to deactivate default profile"> + <condition> + <not><equals arg1="${project.noprofile.build.finalName}" arg2="noprofile"/></not> + </condition> + </fail> + </target> + <target name="test-legacy-pom" depends="initTaskDefs"> <artifact:dependencies> <dependency groupId="geronimo-spec" artifactId="geronimo-spec-javamail" version="1.3.1-rc5" /> Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java?rev=770703&r1=770702&r2=770703&view=diff ============================================================================== --- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java (original) +++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java Fri May 1 14:53:18 2009 @@ -467,6 +467,12 @@ while ( it.hasNext() ) { Profile profile = (Profile) it.next(); + + if ( profile.getId() == null ) + { + throw new BuildException( "Attribute \"id\" is required for profile in pom type." ); + } + if ( profile.getActive() == null || Boolean.parseBoolean( profile.getActive() ) ) { profileManager.explicitlyActivate( profile.getId() ); Added: maven/ant-tasks/trunk/src/test/pom-with-profiles.xml URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/test/pom-with-profiles.xml?rev=770703&view=auto ============================================================================== --- maven/ant-tasks/trunk/src/test/pom-with-profiles.xml (added) +++ maven/ant-tasks/trunk/src/test/pom-with-profiles.xml Fri May 1 14:53:18 2009 @@ -0,0 +1,44 @@ +<?xml version="1.0"?> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>it.ant-tasks</groupId> + <artifactId>profiles</artifactId> + <packaging>jar</packaging> + + <name>profiles</name> + <version>0.10-SNAPSHOT</version> + <description> + Check that the profiles work corretly. + </description> + + <build> + <finalName>noprofile</finalName> + </build> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <finalName>default</finalName> + </build> + </profile> + <profile> + <id>myprofile1</id> + <build> + <finalName>myprofile1</finalName> + </build> + </profile> + <profile> + <id>myprofile2</id> + <build> + <finalName>myprofile2</finalName> + </build> + </profile> + </profiles> +</project> Propchange: maven/ant-tasks/trunk/src/test/pom-with-profiles.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/ant-tasks/trunk/src/test/pom-with-profiles.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision