brett 2003/08/20 06:20:01
Modified: src/test/touchstone-build maven.xml
src/java/org/apache/maven/jelly/tags/maven MavenTag.java
ReactorTag.java
src/java/org/apache/maven MavenConstants.java
Added: src/test/touchstone-build/src/reactor-build/failProperty
project.xml
src/test/touchstone-build/src/reactor-build/failProperty/extra-failure
maven.xml project.xml
src/test/touchstone-build/src/reactor-build/failProperty/failure-1
maven.xml project.xml
src/test/touchstone-build/src/reactor-build/failProperty/failure-2
maven.xml project.xml
src/test/touchstone-build/src/reactor-build/failProperty/success-1
maven.xml project.xml
src/test/touchstone-build/src/reactor-build/failProperty/success-2
maven.xml project.xml
Log:
PR: MAVEN-465
Add failure property to reactor so you can get a list of failed projects for post
processing.
Revision Changes Path
1.41 +215 -0 maven/src/test/touchstone-build/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/maven/src/test/touchstone-build/maven.xml,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- maven.xml 20 Aug 2003 12:37:18 -0000 1.40
+++ maven.xml 20 Aug 2003 13:20:00 -0000 1.41
@@ -53,6 +53,10 @@
<goal name="touchstone-tests">
+ <attainGoal name="test-reactor-failure-property"/>
+ <attainGoal name="test-maven-failure-property"/>
+ <attainGoal name="test-maven-unknown-failure-property"/>
+
<attainGoal name="touchstone-goal-A"/>
<j:set var="checkValue"
value="${pom.getPluginContext('maven-touchstone-plugin').getVariable('touchstone_goal_A_from_plugin')}"/>
<j:if test="${checkValue == 'true'}">
@@ -183,10 +187,221 @@
<!--
|
+ | Check maven.build.failure is set properly by the reactor
+ |
+ -->
+ <goal name="test-reactor-failure-property">
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${mavenBuildFailure}">
+ <fail>maven.build.failure already set</fail>
+ </j:if>
+
+ <!-- Test success -->
+ <maven:reactor
+ basedir="${basedir}"
+ includes="src/reactor-build/failProperty/success-*/project.xml"
+ goals="build"
+ banner="Testing"
+ ignoreFailures="true"
+ />
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${mavenBuildFailure}">
+ <fail>maven.build.failure set incorrectly</fail>
+ </j:if>
+
+ <!-- Test failure -->
+ <maven:reactor
+ basedir="${basedir}"
+
includes="src/reactor-build/failProperty/failure-*/project.xml,src/reactor-build/failProperty/success-*/project.xml"
+ goals="build"
+ banner="Testing"
+ ignoreFailures="true"
+ />
+
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${!mavenBuildFailure}">
+ <fail>maven.build.failure not set</fail>
+ </j:if>
+
+ <j:choose>
+ <j:when test="${size(failedProjects) != 2}">
+ <fail>failedProjects is not length 2</fail>
+ </j:when>
+ <j:otherwise>
+ <j:forEach var="prj" items="${failedProjects}">
+ <j:choose>
+ <j:when test="${prj.artifactId == 'failure-1'}">
+ <echo>failure-1 failed correctly</echo>
+ </j:when>
+ <j:when test="${prj.artifactId == 'failure-2'}">
+ <echo>failure-2 failed correctly</echo>
+ </j:when>
+ <j:otherwise>
+ <fail>${prj.artifactId} failed incorrectly</fail>
+ </j:otherwise>
+ </j:choose>
+ </j:forEach>
+ </j:otherwise>
+ </j:choose>
+
+ <maven:reactor
+ basedir="${basedir}"
+ includes="src/reactor-build/failProperty/extra-failure/project.xml"
+ goals="build"
+ banner="Testing"
+ ignoreFailures="true"
+ />
+
+ <j:choose>
+ <j:when test="${size(failedProjects) != 3}">
+ <fail>failedProjects is not length 3</fail>
+ </j:when>
+ <j:otherwise>
+ <j:forEach var="prj" items="${failedProjects}">
+ <j:choose>
+ <j:when test="${prj.artifactId == 'failure-1'}">
+ <echo>failure-1 failed correctly</echo>
+ </j:when>
+ <j:when test="${prj.artifactId == 'failure-2'}">
+ <echo>failure-2 failed correctly</echo>
+ </j:when>
+ <j:when test="${prj.artifactId == 'extra-failure'}">
+ <echo>extra-failure failed correctly</echo>
+ </j:when>
+ <j:otherwise>
+ <fail>${prj.artifactId} failed incorrectly</fail>
+ </j:otherwise>
+ </j:choose>
+ </j:forEach>
+ </j:otherwise>
+ </j:choose>
+
+ <j:remove var="maven.build.failure" />
+ <j:remove var="failedProjects" />
+ </goal>
+
+ <!--
+ |
+ | Check maven.build.failure is set properly by the maven:maven
+ |
+ -->
+ <goal name="test-maven-failure-property">
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${mavenBuildFailure}">
+ <fail>maven.build.failure already set</fail>
+ </j:if>
+
+ <!-- Test success -->
+ <maven:maven
+ descriptor="${basedir}/src/reactor-build/failProperty/success-1/project.xml"
+ goals="build"
+ ignoreFailures="true"
+ />
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${mavenBuildFailure}">
+ <fail>maven.build.failure set incorrectly</fail>
+ </j:if>
+
+ <!-- Test failure -->
+ <maven:maven
+ descriptor="${basedir}/src/reactor-build/failProperty/failure-1/project.xml"
+ goals="build"
+ ignoreFailures="true"
+ />
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${!mavenBuildFailure}">
+ <fail>maven.build.failure not set</fail>
+ </j:if>
+
+ <j:if test="${failedProjects.isEmpty()}">
+ <fail>Empty failedProjects</fail>
+ </j:if>
+
+ <j:choose>
+ <j:when test="${size(failedProjects) != 1}">
+ <fail>failedProjects should only contain 1 element</fail>
+ </j:when>
+ <j:otherwise>
+ <j:forEach var="prj" items="${failedProjects}">
+ <j:choose>
+ <j:when test="${prj.artifactId == 'failure-1'}">
+ <echo>failure-1 failed correctly</echo>
+ </j:when>
+ <j:otherwise>
+ <fail>${prj.artifactId} failed incorrectly</fail>
+ </j:otherwise>
+ </j:choose>
+ </j:forEach>
+ </j:otherwise>
+ </j:choose>
+
+ <maven:maven
+
descriptor="${basedir}/src/reactor-build/failProperty/extra-failure/project.xml"
+ goals="build"
+ ignoreFailures="true"
+ />
+
+ <j:choose>
+ <j:when test="${size(failedProjects) != 2}">
+ <fail>failedProjects is not length 2</fail>
+ </j:when>
+ <j:otherwise>
+ <j:forEach var="prj" items="${failedProjects}">
+ <j:choose>
+ <j:when test="${prj.artifactId == 'failure-1'}">
+ <echo>failure-1 failed correctly</echo>
+ </j:when>
+ <j:when test="${prj.artifactId == 'extra-failure'}">
+ <echo>extra-failure failed correctly</echo>
+ </j:when>
+ <j:otherwise>
+ <fail>${prj.artifactId} failed incorrectly</fail>
+ </j:otherwise>
+ </j:choose>
+ </j:forEach>
+ </j:otherwise>
+ </j:choose>
+
+ <j:remove var="maven.build.failure" />
+ <j:remove var="failedProjects" />
+ </goal>
+
+ <!--
+ |
+ | Check maven.build.failure is set properly by maven:maven for an unknown
project in the list.
+ |
+ -->
+ <goal name="test-maven-unknown-failure-property">
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${mavenBuildFailure}">
+ <fail>maven.build.failure already set</fail>
+ </j:if>
+
+ <maven:maven
+ descriptor="${basedir}/src/reactor-build/failProperty/unknown/project.xml"
+ goals="build"
+ ignoreFailures="true"
+ />
+ <j:set var="mavenBuildFailure" value="${maven.build.failure}" />
+ <j:if test="${!mavenBuildFailure}">
+ <fail>maven.build.failure not set for unknown project</fail>
+ </j:if>
+
+ <j:remove var="maven.build.failure" />
+ </goal>
+
+ <!--
+ |
| maven.username from within reactor test.
|
-->
<goal name="test-reactor-maven-username">
+ <j:set var="mavenUsername" value="${maven.username}" />
+ <j:if test="${mavenUsername != 'maven'}">
+ <fail>maven.username should be 'maven', but it is '${maven.username}'</fail>
+ </j:if>
+ <j:remove var="mavenUsername" />
+
<maven:reactor
basedir="${basedir}"
includes="src/reactor-build/username_test/project.xml"
1.11 +17 -2 maven/src/java/org/apache/maven/jelly/tags/maven/MavenTag.java
Index: MavenTag.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/MavenTag.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- MavenTag.java 19 Aug 2003 04:25:40 -0000 1.10
+++ MavenTag.java 20 Aug 2003 13:20:00 -0000 1.11
@@ -59,11 +59,14 @@
import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.XMLOutput;
+import org.apache.maven.MavenConstants;
import org.apache.maven.MavenUtils;
import org.apache.maven.jelly.tags.BaseTagSupport;
import org.apache.maven.project.Project;
import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
/**
* A way of running maven as a Jelly tag
@@ -100,9 +103,10 @@
{
checkAttribute( getDescriptor(), "descriptor" );
+ Project project = null;
try
{
- Project project = MavenUtils.getProject( getDescriptor(),
+ project = MavenUtils.getProject( getDescriptor(),
getMavenContext().getMavenSession().getRootContext() );
project.verifyDependencies();
project.processDependencies();
@@ -119,6 +123,17 @@
{
if ( isIgnoreFailures() )
{
+ getMavenContext().setVariable( MavenConstants.BUILD_FAILURE, "true"
);
+ if ( project != null )
+ {
+ Collection c = (Collection) getContext().getVariable(
MavenConstants.FAILED_PROJECTS );
+ if ( c == null )
+ {
+ c = new ArrayList();
+ }
+ c.add( project );
+ getContext().setVariable( MavenConstants.FAILED_PROJECTS, c );
+ }
return;
}
1.36 +20 -2 maven/src/java/org/apache/maven/jelly/tags/maven/ReactorTag.java
Index: ReactorTag.java
===================================================================
RCS file:
/home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/ReactorTag.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ReactorTag.java 19 Aug 2003 04:25:39 -0000 1.35
+++ ReactorTag.java 20 Aug 2003 13:20:00 -0000 1.36
@@ -59,11 +59,13 @@
import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.XMLOutput;
+import org.apache.maven.MavenConstants;
import org.apache.maven.MavenUtils;
import org.apache.maven.project.Project;
import java.io.File;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -94,6 +96,7 @@
public class ReactorTag
extends MavenTag
{
+
/** The glob used to select projects within the base directory. */
private String glob;
@@ -118,6 +121,9 @@
*/
private boolean postProcessing = false;
+ /** Storage for projects that failed in the build. */
+ private Collection failedProjects = new ArrayList();
+
/** Storage for processed projects. */
private ArrayList reactorProjects = new ArrayList();
@@ -397,6 +403,16 @@
}
getContext().setVariable( "reactorProjects", reactorProjects );
+ Collection c = (Collection) getContext().getVariable(
MavenConstants.FAILED_PROJECTS );
+ if ( c == null )
+ {
+ c = new ArrayList( failedProjects );
+ }
+ else
+ {
+ c.addAll( failedProjects );
+ }
+ getContext().setVariable( MavenConstants.FAILED_PROJECTS, c );
}
/**
@@ -439,6 +455,8 @@
*/
public void onException(Project project, Exception e)
{
+ getMavenContext().setVariable( MavenConstants.BUILD_FAILURE, "true" );
+ failedProjects.add( project );
}
/**
1.30 +14 -1 maven/src/java/org/apache/maven/MavenConstants.java
Index: MavenConstants.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/MavenConstants.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- MavenConstants.java 19 Aug 2003 04:31:38 -0000 1.29
+++ MavenConstants.java 20 Aug 2003 13:20:01 -0000 1.30
@@ -181,4 +181,17 @@
/** Dependency classpath tag. */
public static final String SESSION = "maven.session";
+
+ /** Reactor/Maven subproject Build failure tag. */
+ public static final String BUILD_FAILURE = "maven.build.failure";
+
+ /** Reactor/Maven subproject Build failure project list tag. */
+ public static final String FAILED_PROJECTS = "failedProjects";
+
+ /** Maven compile sourceroots. */
+ public static final String COMPILE_SOURCEROOTS = "compile.sourceroots";
+
+ /** Maven test compile sourceroots. */
+ public static final String TEST_COMPILE_SOURCEROOTS =
"test.compile.sourceroots";
+
}
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<pomVersion>3</pomVersion>
<groupId>reactor-test</groupId>
<currentVersion>1.0-beta-9</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://jakarta.apache.org/</url>
<logo>/images/jakarta-logo-blue.gif</logo>
</organization>
<inceptionYear>2001</inceptionYear>
<package>org.apache.maven</package>
<logo>/images/maven.jpg</logo>
<gumpRepositoryId/>
<description/>
<shortDescription/>
<url/>
<issueTrackingUrl/>
<siteAddress/>
<siteDirectory/>
<distributionDirectory/>
<repository/>
<versions/>
<branches/>
<mailingLists/>
<developers/>
<contributors/>
<build>
<nagEmailAddress>[EMAIL PROTECTED]</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources/>
</build>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/extra-failure/maven.xml
Index: maven.xml
===================================================================
<project xmlns:ant="jelly:ant">
<goal name="build">
<ant:echo>E will fail on purpose</ant:echo>
<ant:fail>E fails on purpose</ant:fail>
</goal>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/extra-failure/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>extra-failure</id>
<name>extra-failure</name>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/failure-1/maven.xml
Index: maven.xml
===================================================================
<project xmlns:ant="jelly:ant">
<goal name="build">
<ant:echo>A will fail on purpose</ant:echo>
<ant:fail>A fails on purpose</ant:fail>
</goal>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/failure-1/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>failure-1</id>
<name>failure-1</name>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/failure-2/maven.xml
Index: maven.xml
===================================================================
<project xmlns:ant="jelly:ant">
<goal name="build">
<ant:echo>C will fail on purpose</ant:echo>
<ant:fail>C fails on purpose</ant:fail>
</goal>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/failure-2/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>failure-2</id>
<name>failure-2</name>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/success-1/maven.xml
Index: maven.xml
===================================================================
<project xmlns:ant="jelly:ant">
<goal name="build">
<ant:echo>B succeeds on purpose</ant:echo>
</goal>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/success-1/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>success-1</id>
<name>success-1</name>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/success-2/maven.xml
Index: maven.xml
===================================================================
<project xmlns:ant="jelly:ant">
<goal name="build">
<ant:echo>D succeeds on purpose</ant:echo>
</goal>
</project>
1.1
maven/src/test/touchstone-build/src/reactor-build/failProperty/success-2/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>success-2</id>
<name>success-2</name>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]