Author: carlos Date: Fri Jan 12 15:14:12 2007 New Revision: 495781 URL: http://svn.apache.org/viewvc?view=rev&rev=495781 Log: [MCOMPILER-48] Add maven.compile.failOnError
Added: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/plugin-config.xml (with props) maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/TestCompile0.java (with props) maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/TestCompile0Test.java (with props) Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java?view=diff&rev=495781&r1=495780&r2=495781 ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java (original) +++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java Fri Jan 12 15:14:12 2007 @@ -57,12 +57,19 @@ // ---------------------------------------------------------------------- /** + * Indicates whether the build will continue even if there are compilation errors; defaults to true. + * + * @parameter expression="${maven.compiler.failOnError}" default-value="true" + */ + private boolean failOnError = true; + + /** * Set to true to include debugging information in the compiled class files. * The default value is true. * * @parameter expression="${maven.compiler.debug}" default-value="true" */ - private boolean debug; + private boolean debug = true; /** * Set to true to show messages about what the compiler is doing. @@ -502,7 +509,7 @@ } } - if ( compilationError ) + if ( compilationError && failOnError ) { throw new CompilationFailureException( messages ); } Modified: maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java?view=diff&rev=495781&r1=495780&r2=495781 ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java (original) +++ maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java Fri Jan 12 15:14:12 2007 @@ -246,6 +246,24 @@ } } + public void testCompileFailOnError() + throws Exception + { + CompilerMojo compileMojo = getCompilerMojo( "target/test-classes/unit/compiler-failonerror-test/plugin-config.xml" ); + + setVariableValueToObject( compileMojo, "compilerManager", new CompilerManagerStub( true ) ); + + try + { + compileMojo.execute(); + assertTrue( true ); + } + catch ( CompilationFailureException e ) + { + fail( "The compilation error should have been consumed because failOnError = false" ); + } + } + private CompilerMojo getCompilerMojo( String pomXml ) throws Exception { Added: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/plugin-config.xml?view=auto&rev=495781 ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/plugin-config.xml (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/plugin-config.xml Fri Jan 12 15:14:12 2007 @@ -0,0 +1,35 @@ +<!-- + ~ Copyright 2001-2006 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> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <failOnError>false</failOnError> + <compileSourceRoots> + <compileSourceRoot>${basedir}/target/test-classes/unit/compiler-fail-test/src/main/java</compileSourceRoot> + </compileSourceRoots> + <compilerId>javac</compilerId> + <debug>true</debug> + <outputDirectory>${basedir}/target/test/unit/compiler-fail-test/target/classes</outputDirectory> + <buildDirectory>${basedir}/target/test/unit/compiler-fail-test/target</buildDirectory> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/plugin-config.xml ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/TestCompile0.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/TestCompile0.java?view=auto&rev=495781 ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/TestCompile0.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/TestCompile0.java Fri Jan 12 15:14:12 2007 @@ -0,0 +1,26 @@ +/* + * Copyright 2001-2006 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. + */ + +public class TestCompile0 +{ + + public TestCompile0() + { + + System.out.println("Woo Hoo!"); + } + +} \ No newline at end of file Propchange: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/TestCompile0.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/main/java/TestCompile0.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/TestCompile0Test.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/TestCompile0Test.java?view=auto&rev=495781 ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/TestCompile0Test.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/TestCompile0Test.java Fri Jan 12 15:14:12 2007 @@ -0,0 +1,26 @@ +/* + * Copyright 2001-2006 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. + */ + +import junit.framework.TestCase; + +public class TestCompile0Test + extends TestCase +{ + public void testCompile0Test() + { + TestCompile0 test = new TestCompile0(); + } +} \ No newline at end of file Propchange: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/TestCompile0Test.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-compiler-plugin/src/test/resources/unit/compiler-failonerror-test/src/test/java/TestCompile0Test.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision"