Author: bentmann Date: Mon Sep 1 14:27:17 2008 New Revision: 691066 URL: http://svn.apache.org/viewvc?rev=691066&view=rev Log: [MINVOKER-61] Allow to ignore failures
Added: maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/ maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/pom.xml (with props) maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/ maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/ maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/ maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/pom.xml (with props) Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java Added: maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/pom.xml?rev=691066&view=auto ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/pom.xml (added) +++ maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/pom.xml Mon Sep 1 14:27:17 2008 @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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="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>org.apache.maven.plugins.invoker</groupId> + <artifactId>fail-ignore</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <description>Test to check that a failure in the forked Maven builds is ignored.</description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-invoker-plugin</artifactId> + <version>@pom.version@</version> + <configuration> + <debug>true</debug> + <projectsDirectory>src/it</projectsDirectory> + <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> + <pomIncludes> + <pomInclude>*/pom.xml</pomInclude> + </pomIncludes> + <goals> + <goal>invalid-phase-to-fail-build</goal> + </goals> + <ignoreFailures>true</ignoreFailures> + </configuration> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/pom.xml?rev=691066&view=auto ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/pom.xml (added) +++ maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/pom.xml Mon Sep 1 14:27:17 2008 @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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="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>test</groupId> + <artifactId>fail-ignore</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> +</project> Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/fail-ignore/src/it/project/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=691066&r1=691065&r2=691066&view=diff ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java (original) +++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java Mon Sep 1 14:27:17 2008 @@ -450,6 +450,14 @@ */ private String invokerPropertiesFile; + /** + * A flag controlling whether failures of the sub builds should fail the main build, too. If set to + * <code>true</code>, the main build will proceed even if one or more sub builds failed. + * + * @parameter expression="${maven.test.failure.ignore}" default-value="false" + * @since 1.3 + */ + private boolean ignoreFailures; /** * The supported script interpreters, indexed by the file extension of their associated script files. @@ -555,12 +563,27 @@ if ( !failures.isEmpty() ) { - getLog().error( "The following builds failed:" ); + String heading = "The following builds failed:"; + if ( ignoreFailures ) + { + getLog().warn( heading ); + } + else + { + getLog().error( heading ); + } for ( final Iterator it = failures.iterator(); it.hasNext(); ) { - final String pom = (String) it.next(); - getLog().error( "* " + pom ); + String item = "* " + (String) it.next(); + if ( ignoreFailures ) + { + getLog().warn( item ); + } + else + { + getLog().error( item ); + } } getLog().info( "---------------------------------------" ); @@ -569,9 +592,16 @@ if ( !failures.isEmpty() ) { - String message = failures.size() + " builds failed."; + String message = failures.size() + " build" + ( failures.size() == 1 ? "" : "s" ) + " failed."; - throw new MojoFailureException( this, message, message ); + if ( ignoreFailures ) + { + getLog().warn( "Ignoring that " + message ); + } + else + { + throw new MojoFailureException( this, message, message ); + } } }