From a55eb4eba1d81787fbffd07a5807d6a0b013e844 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Sun, 23 Aug 2020 21:58:13 +1000 Subject: [PATCH 1/4] add compiler its test with maven compiler plugin Signed-off-by: olivier lamy --- plexus-compiler-its/pom.xml | 58 ++++++++++++ .../error-prone-compiler/invoker.properties | 20 ++++ .../src/main/it/error-prone-compiler/pom.xml | 91 +++++++++++++++++++ .../src/main/java/MyClass.java | 29 ++++++ .../src/test/java/MyTest.java | 32 +++++++ .../it/error-prone-compiler/verify.groovy | 24 +++++ plexus-compiler-its/src/main/it/settings.xml | 55 +++++++++++ .../main/it/simple-javac/invoker.properties | 20 ++++ .../src/main/it/simple-javac/pom.xml | 66 ++++++++++++++ .../simple-javac/src/main/java/MyClass.java | 23 +++++ .../it/simple-javac/src/test/java/MyTest.java | 26 ++++++ .../src/main/it/simple-javac/verify.groovy | 23 +++++ pom.xml | 1 + 13 files changed, 468 insertions(+) create mode 100644 plexus-compiler-its/pom.xml create mode 100644 plexus-compiler-its/src/main/it/error-prone-compiler/invoker.properties create mode 100644 plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml create mode 100644 plexus-compiler-its/src/main/it/error-prone-compiler/src/main/java/MyClass.java create mode 100644 plexus-compiler-its/src/main/it/error-prone-compiler/src/test/java/MyTest.java create mode 100644 plexus-compiler-its/src/main/it/error-prone-compiler/verify.groovy create mode 100644 plexus-compiler-its/src/main/it/settings.xml create mode 100644 plexus-compiler-its/src/main/it/simple-javac/invoker.properties create mode 100644 plexus-compiler-its/src/main/it/simple-javac/pom.xml create mode 100644 plexus-compiler-its/src/main/it/simple-javac/src/main/java/MyClass.java create mode 100644 plexus-compiler-its/src/main/it/simple-javac/src/test/java/MyTest.java create mode 100644 plexus-compiler-its/src/main/it/simple-javac/verify.groovy diff --git a/plexus-compiler-its/pom.xml b/plexus-compiler-its/pom.xml new file mode 100644 index 00000000..b03aef10 --- /dev/null +++ b/plexus-compiler-its/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + + + org.codehaus.plexus + plexus-compiler + 2.8.8-SNAPSHOT + + + plexus-compiler-its + pom + + Plexus Compiler It Tests + + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + + + org.codehaus.plexus + plexus-compiler-javac + + + + + + org.apache.maven.plugins + maven-invoker-plugin + 3.2.1 + + + integration-tests + verify + + install + run + verify + + + true + src/main/it + ${project.build.directory}/it + verify + ${project.build.directory}/local-repo + src/main/it/settings.xml + + clean + test-compile + + + + + + + + diff --git a/plexus-compiler-its/src/main/it/error-prone-compiler/invoker.properties b/plexus-compiler-its/src/main/it/error-prone-compiler/invoker.properties new file mode 100644 index 00000000..0ebe374a --- /dev/null +++ b/plexus-compiler-its/src/main/it/error-prone-compiler/invoker.properties @@ -0,0 +1,20 @@ +# 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. + +invoker.java.version = 1.8+ +invoker.goals = clean test-compile +invoker.buildResult = failure diff --git a/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml b/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml new file mode 100644 index 00000000..1af53aa2 --- /dev/null +++ b/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml @@ -0,0 +1,91 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.compiler.it + error-prone-compiler + 1.0-SNAPSHOT + + Test for default configuration + + + UTF-8 + 9+181-r4173-1 + + + + + junit + junit + 3.8.2 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + -XDcompilePolicy=simple + -Xplugin:ErrorProne + + + + com.google.errorprone + error_prone_core + 2.4.0 + + + + + + + + + jdk8 + + 1.8 + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + true + + -J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${javac.version}/javac-${javac.version}.jar + + + + + + + + diff --git a/plexus-compiler-its/src/main/it/error-prone-compiler/src/main/java/MyClass.java b/plexus-compiler-its/src/main/it/error-prone-compiler/src/main/java/MyClass.java new file mode 100644 index 00000000..15c7cd2c --- /dev/null +++ b/plexus-compiler-its/src/main/it/error-prone-compiler/src/main/java/MyClass.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 MyClass +{ + + public static void main(String[] args) { + // error: dead exception + // BUG: Diagnostic contains: throw new RuntimeException + new RuntimeException("Not thrown, and reference lost"); + } + +} diff --git a/plexus-compiler-its/src/main/it/error-prone-compiler/src/test/java/MyTest.java b/plexus-compiler-its/src/main/it/error-prone-compiler/src/test/java/MyTest.java new file mode 100644 index 00000000..316bc84f --- /dev/null +++ b/plexus-compiler-its/src/main/it/error-prone-compiler/src/test/java/MyTest.java @@ -0,0 +1,32 @@ +/* + * 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; + +import java.util.*; + +public class MyTest + extends TestCase +{ + // InfiniteRecursion + int oops() { + return oops(); + } + +} diff --git a/plexus-compiler-its/src/main/it/error-prone-compiler/verify.groovy b/plexus-compiler-its/src/main/it/error-prone-compiler/verify.groovy new file mode 100644 index 00000000..5fca29d9 --- /dev/null +++ b/plexus-compiler-its/src/main/it/error-prone-compiler/verify.groovy @@ -0,0 +1,24 @@ +/* + * 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. + */ +def logFile = new File( basedir, 'build.log' ) +assert logFile.exists() +content = logFile.text + +assert content.contains( 'Compilation failure' ) +assert content.contains( '[DeadException] Exception created but not thrown' ) diff --git a/plexus-compiler-its/src/main/it/settings.xml b/plexus-compiler-its/src/main/it/settings.xml new file mode 100644 index 00000000..c8f77f0b --- /dev/null +++ b/plexus-compiler-its/src/main/it/settings.xml @@ -0,0 +1,55 @@ + + + + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + diff --git a/plexus-compiler-its/src/main/it/simple-javac/invoker.properties b/plexus-compiler-its/src/main/it/simple-javac/invoker.properties new file mode 100644 index 00000000..f419c5fa --- /dev/null +++ b/plexus-compiler-its/src/main/it/simple-javac/invoker.properties @@ -0,0 +1,20 @@ +# 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. + +invoker.java.version = 1.8+ +invoker.goals = clean test-compile +#invoker.buildResult = failure diff --git a/plexus-compiler-its/src/main/it/simple-javac/pom.xml b/plexus-compiler-its/src/main/it/simple-javac/pom.xml new file mode 100644 index 00000000..767be0a7 --- /dev/null +++ b/plexus-compiler-its/src/main/it/simple-javac/pom.xml @@ -0,0 +1,66 @@ + + + + + 4.0.0 + + org.codehaus.plexus.compiler.it + simple-javac + 1.0-SNAPSHOT + + Test for default configuration + + + UTF-8 + + + + + junit + junit + 3.8.2 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + -Xlint:-path + + + + + org.codehaus.plexus + plexus-compiler-javac + @pom.version@ + + + + + + + diff --git a/plexus-compiler-its/src/main/it/simple-javac/src/main/java/MyClass.java b/plexus-compiler-its/src/main/it/simple-javac/src/main/java/MyClass.java new file mode 100644 index 00000000..4945381a --- /dev/null +++ b/plexus-compiler-its/src/main/it/simple-javac/src/main/java/MyClass.java @@ -0,0 +1,23 @@ +/* + * 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/plexus-compiler-its/src/main/it/simple-javac/src/test/java/MyTest.java b/plexus-compiler-its/src/main/it/simple-javac/src/test/java/MyTest.java new file mode 100644 index 00000000..46ba41d4 --- /dev/null +++ b/plexus-compiler-its/src/main/it/simple-javac/src/test/java/MyTest.java @@ -0,0 +1,26 @@ +/* + * 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 +{ + +} diff --git a/plexus-compiler-its/src/main/it/simple-javac/verify.groovy b/plexus-compiler-its/src/main/it/simple-javac/verify.groovy new file mode 100644 index 00000000..06136d7f --- /dev/null +++ b/plexus-compiler-its/src/main/it/simple-javac/verify.groovy @@ -0,0 +1,23 @@ +/* + * 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. + */ +def mainClass = new File( basedir, "target/classes/MyClass.class" ) +assert mainClass.exists() + +def testClass = new File( basedir, "target/test-classes/MyTest.class" ) +assert testClass.exists() diff --git a/pom.xml b/pom.xml index c6cb2fcd..8991fdf7 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ plexus-compiler-manager plexus-compilers plexus-compiler-test + plexus-compiler-its From 86cae0ec28a9825bee1cab54a7bc39dff5630ffa Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Sun, 23 Aug 2020 22:03:33 +1000 Subject: [PATCH 2/4] fix dependencyManagement Signed-off-by: olivier lamy --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 8991fdf7..2ef06a3b 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,16 @@ plexus-compiler-test ${project.version} + + org.codehaus.plexus + plexus-compiler-javac-errorprone + ${project.version} + + + org.codehaus.plexus + plexus-compiler-javac + ${project.version} + org.codehaus.plexus plexus-component-annotations From 776925057e1122be10ebb0367c770bb7be487e5e Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Mon, 24 Aug 2020 09:49:49 +1000 Subject: [PATCH 3/4] it compiler test source/target 8 as minimum Signed-off-by: olivier lamy --- plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml b/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml index 1af53aa2..dbbc85de 100644 --- a/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml +++ b/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml @@ -49,6 +49,8 @@ maven-compiler-plugin 3.8.1 + 8 + 8 -XDcompilePolicy=simple -Xplugin:ErrorProne @@ -76,8 +78,6 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 true -J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${javac.version}/javac-${javac.version}.jar From 58966d6e3d68b10612674cc2536110adf3b67455 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Mon, 24 Aug 2020 09:52:40 +1000 Subject: [PATCH 4/4] it compiler test source/target 8 as minimum Signed-off-by: olivier lamy --- plexus-compiler-its/src/main/it/simple-javac/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plexus-compiler-its/src/main/it/simple-javac/pom.xml b/plexus-compiler-its/src/main/it/simple-javac/pom.xml index 767be0a7..c3bdbe6e 100644 --- a/plexus-compiler-its/src/main/it/simple-javac/pom.xml +++ b/plexus-compiler-its/src/main/it/simple-javac/pom.xml @@ -48,6 +48,8 @@ maven-compiler-plugin 3.8.1 + 8 + 8 -Xlint:-path