diff --git a/0001-MCOMPILER-284-maven.test.skip-doesn-t-skip-test-comp.patch b/0001-MCOMPILER-284-maven.test.skip-doesn-t-skip-test-comp.patch new file mode 100644 index 0000000..133df9c --- /dev/null +++ b/0001-MCOMPILER-284-maven.test.skip-doesn-t-skip-test-comp.patch @@ -0,0 +1,501 @@ +From e1d2e45e48a5e46b800cbedbb11dabb218b12e01 Mon Sep 17 00:00:00 2001 +From: gboue +Date: Fri, 4 Nov 2016 19:48:26 +0000 +Subject: [PATCH] [MCOMPILER-284] maven.test.skip doesn't skip test compilation + +--- + src/it/MCOMPILER-284/pom.xml | 59 ++++++++++++++++++++++ + .../src/main/java/com/foo/MyClass.java | 25 +++++++++ + .../src/test/java/com/foo/MyTest.java | 28 ++++++++++ + src/it/MCOMPILER-284/verify.bsh | 37 ++++++++++++++ + .../maven/plugin/compiler/TestCompilerMojo.java | 1 + + .../plugin/compiler/CompilerMojoTestCase.java | 42 +++++++++++++++ + .../unit/compiler-skip-main/plugin-config.xml | 37 ++++++++++++++ + .../src/main/java/TestSkipMainCompile0.java | 29 +++++++++++ + .../src/test/java/TestSkipMainCompile0Test.java | 29 +++++++++++ + .../unit/compiler-skip-test/plugin-config.xml | 37 ++++++++++++++ + .../src/main/java/TestSkipTestCompile0.java | 29 +++++++++++ + .../src/test/java/TestSkipTestCompile0Test.java | 29 +++++++++++ + 12 files changed, 382 insertions(+) + create mode 100644 src/it/MCOMPILER-284/pom.xml + create mode 100644 src/it/MCOMPILER-284/src/main/java/com/foo/MyClass.java + create mode 100644 src/it/MCOMPILER-284/src/test/java/com/foo/MyTest.java + create mode 100644 src/it/MCOMPILER-284/verify.bsh + create mode 100644 src/test/resources/unit/compiler-skip-main/plugin-config.xml + create mode 100644 src/test/resources/unit/compiler-skip-main/src/main/java/TestSkipMainCompile0.java + create mode 100644 src/test/resources/unit/compiler-skip-main/src/test/java/TestSkipMainCompile0Test.java + create mode 100644 src/test/resources/unit/compiler-skip-test/plugin-config.xml + create mode 100644 src/test/resources/unit/compiler-skip-test/src/main/java/TestSkipTestCompile0.java + create mode 100644 src/test/resources/unit/compiler-skip-test/src/test/java/TestSkipTestCompile0Test.java + +diff --git a/src/it/MCOMPILER-284/pom.xml b/src/it/MCOMPILER-284/pom.xml +new file mode 100644 +index 0000000..2518d9c +--- /dev/null ++++ b/src/it/MCOMPILER-284/pom.xml +@@ -0,0 +1,59 @@ ++ ++ ++ ++ ++ 4.0.0 ++ ++ org.apache.maven.plugins.compiler.it ++ mcompiler284 ++ 1.0-SNAPSHOT ++ ++ https://issues.apache.org/jira/browse/MCOMPILER-284 ++ ++ ++ UTF-8 ++ ++ ++ ++ ++ junit ++ junit ++ 3.8.2 ++ test ++ ++ ++ ++ ++ ++ ++ org.apache.maven.plugins ++ maven-compiler-plugin ++ @project.version@ ++ ++ true ++ true ++ ++ ++ ++ ++ ++ +diff --git a/src/it/MCOMPILER-284/src/main/java/com/foo/MyClass.java b/src/it/MCOMPILER-284/src/main/java/com/foo/MyClass.java +new file mode 100644 +index 0000000..7370ac0 +--- /dev/null ++++ b/src/it/MCOMPILER-284/src/main/java/com/foo/MyClass.java +@@ -0,0 +1,25 @@ ++package com.foo; ++ ++/* ++ * 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. ++ */ ++ ++public class MyClass ++{ ++ ++} +diff --git a/src/it/MCOMPILER-284/src/test/java/com/foo/MyTest.java b/src/it/MCOMPILER-284/src/test/java/com/foo/MyTest.java +new file mode 100644 +index 0000000..f152b90 +--- /dev/null ++++ b/src/it/MCOMPILER-284/src/test/java/com/foo/MyTest.java +@@ -0,0 +1,28 @@ ++package com.foo; ++ ++/* ++ * 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. ++ */ ++ ++import junit.framework.TestCase; ++ ++public class MyTest ++ extends TestCase ++{ ++ private MyClass myClass = new MyClass(); ++} +diff --git a/src/it/MCOMPILER-284/verify.bsh b/src/it/MCOMPILER-284/verify.bsh +new file mode 100644 +index 0000000..35e28c7 +--- /dev/null ++++ b/src/it/MCOMPILER-284/verify.bsh +@@ -0,0 +1,37 @@ ++/* ++ * 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. ++ */ ++ ++import java.io.*; ++import java.util.*; ++ ++File mainClass = new File( basedir, "target/classes/com/foo/MyClass.class" ); ++if ( mainClass.isFile() ) ++{ ++ System.out.println( "Main class is present but was skipped: " + mainClass ); ++ return false; ++} ++ ++File testClass = new File( basedir, "target/test-classes/com/foo/MyTest.class" ); ++if ( testClass.isFile() ) ++{ ++ System.out.println( "Test class is present but was skipped: " + testClass ); ++ return false; ++} ++ ++return true; +diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +index 4f5d0db..56d0973 100644 +--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java ++++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +@@ -160,6 +160,7 @@ public class TestCompilerMojo + if ( skip ) + { + getLog().info( "Not compiling test sources" ); ++ return; + } + super.execute(); + } +diff --git a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java +index 36bf754..e80cbfc 100644 +--- a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java ++++ b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java +@@ -311,6 +311,48 @@ public class CompilerMojoTestCase + fail( "The compilation error should have been consumed because failOnError = false" ); + } + } ++ ++ /** ++ * Tests that setting 'skipMain' to true skips compilation of the main Java source files, but that test Java source ++ * files are still compiled. ++ * @throws Exception ++ */ ++ public void testCompileSkipMain() ++ throws Exception ++ { ++ CompilerMojo compileMojo = getCompilerMojo( "target/test-classes/unit/compiler-skip-main/plugin-config.xml" ); ++ setVariableValueToObject( compileMojo, "skipMain", true ); ++ compileMojo.execute(); ++ File testClass = new File( compileMojo.getOutputDirectory(), "TestSkipMainCompile0.class" ); ++ assertFalse( testClass.exists() ); ++ ++ TestCompilerMojo testCompileMojo = ++ getTestCompilerMojo( compileMojo, "target/test-classes/unit/compiler-skip-main/plugin-config.xml" ); ++ testCompileMojo.execute(); ++ testClass = new File( testCompileMojo.getOutputDirectory(), "TestSkipMainCompile0Test.class" ); ++ assertTrue( testClass.exists() ); ++ } ++ ++ /** ++ * Tests that setting 'skip' to true skips compilation of the test Java source files, but that main Java source ++ * files are still compiled. ++ * @throws Exception ++ */ ++ public void testCompileSkipTest() ++ throws Exception ++ { ++ CompilerMojo compileMojo = getCompilerMojo( "target/test-classes/unit/compiler-skip-test/plugin-config.xml" ); ++ compileMojo.execute(); ++ File testClass = new File( compileMojo.getOutputDirectory(), "TestSkipTestCompile0.class" ); ++ assertTrue( testClass.exists() ); ++ ++ TestCompilerMojo testCompileMojo = ++ getTestCompilerMojo( compileMojo, "target/test-classes/unit/compiler-skip-test/plugin-config.xml" ); ++ setVariableValueToObject( testCompileMojo, "skip", true ); ++ testCompileMojo.execute(); ++ testClass = new File( testCompileMojo.getOutputDirectory(), "TestSkipTestCompile0Test.class" ); ++ assertFalse( testClass.exists() ); ++ } + + private CompilerMojo getCompilerMojo( String pomXml ) + throws Exception +diff --git a/src/test/resources/unit/compiler-skip-main/plugin-config.xml b/src/test/resources/unit/compiler-skip-main/plugin-config.xml +new file mode 100644 +index 0000000..648718a +--- /dev/null ++++ b/src/test/resources/unit/compiler-skip-main/plugin-config.xml +@@ -0,0 +1,37 @@ ++ ++ ++ ++ ++ ++ ++ maven-compiler-plugin ++ ++ ++ ${basedir}/target/test-classes/unit/compiler-skip-main/src/main/java ++ ++ javac ++ true ++ ${basedir}/target/test/unit/compiler-skip-main/target/classes ++ ${basedir}/target/test/unit/compiler-skip-main/target ++ ++ ++ ++ ++ +diff --git a/src/test/resources/unit/compiler-skip-main/src/main/java/TestSkipMainCompile0.java b/src/test/resources/unit/compiler-skip-main/src/main/java/TestSkipMainCompile0.java +new file mode 100644 +index 0000000..f1788b4 +--- /dev/null ++++ b/src/test/resources/unit/compiler-skip-main/src/main/java/TestSkipMainCompile0.java +@@ -0,0 +1,29 @@ ++/* ++ * 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. ++ */ ++ ++public class TestSkipMainCompile0 ++{ ++ ++ public TestSkipMainCompile0() ++ { ++ ++ System.out.println( "Woo Hoo!" ); ++ } ++ ++} +\ No newline at end of file +diff --git a/src/test/resources/unit/compiler-skip-main/src/test/java/TestSkipMainCompile0Test.java b/src/test/resources/unit/compiler-skip-main/src/test/java/TestSkipMainCompile0Test.java +new file mode 100644 +index 0000000..3058998 +--- /dev/null ++++ b/src/test/resources/unit/compiler-skip-main/src/test/java/TestSkipMainCompile0Test.java +@@ -0,0 +1,29 @@ ++/* ++ * 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. ++ */ ++ ++import junit.framework.TestCase; ++ ++public class TestSkipMainCompile0Test ++ extends TestCase ++{ ++ public void testSkipMainCompile0Test() ++ { ++ ++ } ++} +\ No newline at end of file +diff --git a/src/test/resources/unit/compiler-skip-test/plugin-config.xml b/src/test/resources/unit/compiler-skip-test/plugin-config.xml +new file mode 100644 +index 0000000..da593ea +--- /dev/null ++++ b/src/test/resources/unit/compiler-skip-test/plugin-config.xml +@@ -0,0 +1,37 @@ ++ ++ ++ ++ ++ ++ ++ maven-compiler-plugin ++ ++ ++ ${basedir}/target/test-classes/unit/compiler-skip-test/src/main/java ++ ++ javac ++ true ++ ${basedir}/target/test/unit/compiler-skip-test/target/classes ++ ${basedir}/target/test/unit/compiler-skip-test/target ++ ++ ++ ++ ++ +diff --git a/src/test/resources/unit/compiler-skip-test/src/main/java/TestSkipTestCompile0.java b/src/test/resources/unit/compiler-skip-test/src/main/java/TestSkipTestCompile0.java +new file mode 100644 +index 0000000..95bcc5a +--- /dev/null ++++ b/src/test/resources/unit/compiler-skip-test/src/main/java/TestSkipTestCompile0.java +@@ -0,0 +1,29 @@ ++/* ++ * 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. ++ */ ++ ++public class TestSkipTestCompile0 ++{ ++ ++ public TestSkipTestCompile0() ++ { ++ ++ System.out.println( "Woo Hoo!" ); ++ } ++ ++} +\ No newline at end of file +diff --git a/src/test/resources/unit/compiler-skip-test/src/test/java/TestSkipTestCompile0Test.java b/src/test/resources/unit/compiler-skip-test/src/test/java/TestSkipTestCompile0Test.java +new file mode 100644 +index 0000000..aa5e09d +--- /dev/null ++++ b/src/test/resources/unit/compiler-skip-test/src/test/java/TestSkipTestCompile0Test.java +@@ -0,0 +1,29 @@ ++/* ++ * 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. ++ */ ++ ++import junit.framework.TestCase; ++ ++public class TestSkipTestCompile0Test ++ extends TestCase ++{ ++ public void testSkipTestCompile0Test() ++ { ++ TestSkipTestCompile0 test = new TestSkipTestCompile0(); ++ } ++} +\ No newline at end of file +-- +2.7.4 + diff --git a/maven-compiler-plugin.spec b/maven-compiler-plugin.spec index 8260a5a..aba0201 100644 --- a/maven-compiler-plugin.spec +++ b/maven-compiler-plugin.spec @@ -1,6 +1,6 @@ Name: maven-compiler-plugin Version: 3.6.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Maven Compiler Plugin License: ASL 2.0 URL: http://maven.apache.org/plugins/maven-compiler-plugin @@ -8,17 +8,20 @@ BuildArch: noarch Source0: http://repo1.maven.org/maven2/org/apache/maven/plugins/%{name}/%{version}/%{name}-%{version}-source-release.zip +# https://issues.apache.org/jira/browse/MCOMPILER-284 +Patch0: 0001-MCOMPILER-284-maven.test.skip-doesn-t-skip-test-comp.patch + BuildRequires: maven-local BuildRequires: mvn(org.apache.maven:maven-artifact) BuildRequires: mvn(org.apache.maven:maven-core) BuildRequires: mvn(org.apache.maven:maven-plugin-api) BuildRequires: mvn(org.apache.maven.plugins:maven-plugins:pom:) BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations) -BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin) BuildRequires: mvn(org.apache.maven.shared:maven-shared-incremental) BuildRequires: mvn(org.apache.maven.shared:maven-shared-utils) -BuildRequires: mvn(org.codehaus.plexus:plexus-compiler-api) >= 2.0 +BuildRequires: mvn(org.codehaus.plexus:plexus-compiler-api) BuildRequires: mvn(org.codehaus.plexus:plexus-compiler-manager) +BuildRequires: mvn(org.ow2.asm:asm) %description The Compiler Plugin is used to compile the sources of your project. @@ -32,6 +35,8 @@ API documentation for %{name}. %prep %setup -q +%patch0 -p1 + %build %mvn_build -f @@ -45,6 +50,9 @@ API documentation for %{name}. %license LICENSE NOTICE %changelog +* Tue Nov 08 2016 Michael Simacek - 3.6.0-2 +- Add upstream patch for broken test skipping + * Mon Oct 31 2016 Michael Simacek - 3.6.0-1 - Update to upstream version 3.6.0