diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index ed7e58c4..f028fa53 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -24,7 +24,7 @@ on: jobs: build: name: Verify - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 with: # maven-args: "-Dinvoker.parallelThreads=2" cannot do this as this generate some concurrent download issues jdk-distribution-matrix: '[ "temurin", "zulu", "microsoft", "adopt-openj9" ]' diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index b44872cf..1049eaa3 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -22,4 +22,4 @@ on: - master jobs: update_release_draft: - uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v3 + uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4 diff --git a/pom.xml b/pom.xml index c66180b0..90df37c7 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-compiler-plugin - 3.12.1 + 3.13.0 maven-plugin Apache Maven Compiler Plugin @@ -48,7 +48,7 @@ under the License. scm:git:https://github.com/apache/maven-compiler-plugin.git scm:git:https://github.com/apache/maven-compiler-plugin.git - maven-compiler-plugin-3.12.1 + maven-compiler-plugin-3.13.0 https://github.com/apache/maven-compiler-plugin/tree/${project.scm.tag} @@ -67,8 +67,8 @@ under the License. - 3.2.5 - 2.14.2 + 3.6.3 + 2.15.0 2.4.21 3.7.0 @@ -76,7 +76,7 @@ under the License. 1.2.0 8 false - 2023-12-21T07:45:23Z + 2024-03-15T07:27:59Z org.apache.maven.plugins.compiler.its @@ -127,6 +127,10 @@ under the License. org.apache.maven.shared maven-shared-utils + + org.codehaus.plexus + plexus-component-annotations + @@ -160,14 +164,7 @@ under the License. org.apache.maven.plugin-testing maven-plugin-testing-harness - 3.3.0 - test - - - - org.apache.maven - maven-compat - ${mavenVersion} + 4.0.0-alpha-2 test @@ -218,6 +215,29 @@ under the License. + + org.apache.maven.plugins + maven-plugin-report-plugin + + + + from 3.13.0 + 3.6.3 + 8 + + + from 3.9.0 to 3.12.1 + 3.2.5 + 8 + + + from 3.0 to 3.8.1 + 3.0 + 7 + + + + diff --git a/src/it/MCOMPILER-170/invoker.properties b/src/it/MCOMPILER-170/invoker.properties index 9f346f93..868a2586 100644 --- a/src/it/MCOMPILER-170/invoker.properties +++ b/src/it/MCOMPILER-170/invoker.properties @@ -16,4 +16,3 @@ # under the License. invoker.goals = clean compile -T4 -invoker.maven.version = 3.0+ diff --git a/src/it/MCOMPILER-275_separate-moduleinfo/invoker.properties b/src/it/MCOMPILER-275_separate-moduleinfo/invoker.properties index 66f3f58e..028c62b2 100644 --- a/src/it/MCOMPILER-275_separate-moduleinfo/invoker.properties +++ b/src/it/MCOMPILER-275_separate-moduleinfo/invoker.properties @@ -17,5 +17,3 @@ invoker.java.version = 1.8+ invoker.toolchain.jdk.version=1.9 -# Due to toolchain support -invoker.maven.version = 3.3.1+ \ No newline at end of file diff --git a/src/it/MCOMPILER-298/invoker.properties b/src/it/MCOMPILER-298/invoker.properties index 928055c1..b1a04637 100644 --- a/src/it/MCOMPILER-298/invoker.properties +++ b/src/it/MCOMPILER-298/invoker.properties @@ -15,5 +15,4 @@ # specific language governing permissions and limitations # under the License. -invoker.java.version = 1.8+ invoker.goals = test diff --git a/src/it/MCOMPILER-525/pom.xml b/src/it/MCOMPILER-525/pom.xml index 48de91e9..ce4080ea 100644 --- a/src/it/MCOMPILER-525/pom.xml +++ b/src/it/MCOMPILER-525/pom.xml @@ -35,12 +35,12 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + @version.maven-jar-plugin@ org.apache.maven.plugins maven-antrun-plugin - 3.1.0 + @version.maven-antrun-plugin@ touch diff --git a/src/it/mcompiler-120/invoker.properties b/src/it/mcompiler-120/invoker.properties index 86f9130c..98a8e954 100644 --- a/src/it/mcompiler-120/invoker.properties +++ b/src/it/mcompiler-120/invoker.properties @@ -17,4 +17,3 @@ invoker.goals = clean compile invoker.buildResult = failure -invoker.java.version = 1.6+ diff --git a/src/it/multirelease-patterns/multimodule/multirelease/pom.xml b/src/it/multirelease-patterns/multimodule/multirelease/pom.xml index 220864cd..d7af7c80 100644 --- a/src/it/multirelease-patterns/multimodule/multirelease/pom.xml +++ b/src/it/multirelease-patterns/multimodule/multirelease/pom.xml @@ -35,7 +35,7 @@ maven-assembly-plugin - 3.1.0 + @version.maven-assembly-plugin@ false diff --git a/src/it/multirelease-patterns/multimodule/pom.xml b/src/it/multirelease-patterns/multimodule/pom.xml index bf411e67..b4e48129 100644 --- a/src/it/multirelease-patterns/multimodule/pom.xml +++ b/src/it/multirelease-patterns/multimodule/pom.xml @@ -39,7 +39,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.21.0 + @version.maven-surefire@ diff --git a/src/it/multirelease-patterns/multiproject/multirelease-base/pom.xml b/src/it/multirelease-patterns/multiproject/multirelease-base/pom.xml index fbf2bcb0..6c5ad95b 100644 --- a/src/it/multirelease-patterns/multiproject/multirelease-base/pom.xml +++ b/src/it/multirelease-patterns/multiproject/multirelease-base/pom.xml @@ -92,7 +92,6 @@ org.apache.maven.plugins maven-dependency-plugin - 3.1.0 add-java9-supplement diff --git a/src/it/multirelease-patterns/multiproject/pom.xml b/src/it/multirelease-patterns/multiproject/pom.xml index 533282fd..79740d27 100644 --- a/src/it/multirelease-patterns/multiproject/pom.xml +++ b/src/it/multirelease-patterns/multiproject/pom.xml @@ -35,10 +35,20 @@ maven-compiler-plugin @project.version@ + + org.apache.maven.plugins + maven-dependency-plugin + @version.maven-dependency-plugin@ + + + org.apache.maven.plugins + maven-jar-plugin + @version.maven-jar-plugin@ + org.apache.maven.plugins maven-surefire-plugin - 2.22.0 + @version.maven-surefire@ diff --git a/src/it/multirelease-patterns/packaging-plugin/pom.xml b/src/it/multirelease-patterns/packaging-plugin/pom.xml index 593d4a13..88fde2d5 100644 --- a/src/it/multirelease-patterns/packaging-plugin/pom.xml +++ b/src/it/multirelease-patterns/packaging-plugin/pom.xml @@ -33,7 +33,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.21.0 + @version.maven-surefire@ true @@ -56,7 +56,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.21.0 + @version.maven-surefire@ diff --git a/src/it/multirelease-patterns/singleproject-runtime/invoker.properties b/src/it/multirelease-patterns/singleproject-runtime/invoker.properties index 318b31a7..a15f4d08 100644 --- a/src/it/multirelease-patterns/singleproject-runtime/invoker.properties +++ b/src/it/multirelease-patterns/singleproject-runtime/invoker.properties @@ -14,5 +14,4 @@ # 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 = verify \ No newline at end of file diff --git a/src/it/multirelease-patterns/singleproject-runtime/pom.xml b/src/it/multirelease-patterns/singleproject-runtime/pom.xml index a5be9ce8..fb8647e3 100644 --- a/src/it/multirelease-patterns/singleproject-runtime/pom.xml +++ b/src/it/multirelease-patterns/singleproject-runtime/pom.xml @@ -38,10 +38,20 @@ 1.8 + + org.apache.maven.plugins + maven-jar-plugin + @version.maven-jar-plugin@ + + + org.apache.maven.plugins + maven-failsafe-plugin + @version.maven-surefire@ + org.apache.maven.plugins maven-surefire-plugin - 2.21.0 + @version.maven-surefire@ true @@ -54,7 +64,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.21.0 diff --git a/src/it/multirelease-patterns/singleproject-toolchains/invoker.properties b/src/it/multirelease-patterns/singleproject-toolchains/invoker.properties index 3e89fdde..193b2ad7 100644 --- a/src/it/multirelease-patterns/singleproject-toolchains/invoker.properties +++ b/src/it/multirelease-patterns/singleproject-toolchains/invoker.properties @@ -16,5 +16,3 @@ # under the License. invoker.goals = verify -Pmulti-jar invoker.toolchain.jdk.version=1.9 -# Due to toolchain support -invoker.maven.version = 3.3.1+ diff --git a/src/it/multirelease-patterns/singleproject-toolchains/pom.xml b/src/it/multirelease-patterns/singleproject-toolchains/pom.xml index 154f8ae6..39197623 100644 --- a/src/it/multirelease-patterns/singleproject-toolchains/pom.xml +++ b/src/it/multirelease-patterns/singleproject-toolchains/pom.xml @@ -44,7 +44,7 @@ org.apache.maven.plugins maven-toolchains-plugin - 1.1 + 3.1.0 @@ -114,7 +114,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.21.0 + @version.maven-surefire@ @@ -200,7 +200,7 @@ maven-surefire-plugin - 2.21.0 + @version.maven-surefire@ ${env.JAVA_HOME}/bin/java @@ -245,7 +245,7 @@ org.apache.maven.plugins maven-jar-plugin - 2.4 + @version.maven-jar-plugin@ diff --git a/src/it/non-english-warnings/pom.xml b/src/it/non-english-warnings/pom.xml index aaadacd1..efb74e80 100644 --- a/src/it/non-english-warnings/pom.xml +++ b/src/it/non-english-warnings/pom.xml @@ -43,7 +43,7 @@ org.apache.maven.plugins maven-compiler-plugin - @pom.version@ + @project.version@ false true diff --git a/src/it/release-without-profile-fork/invoker.properties b/src/it/release-without-profile-fork/invoker.properties new file mode 100644 index 00000000..0659ac55 --- /dev/null +++ b/src/it/release-without-profile-fork/invoker.properties @@ -0,0 +1,18 @@ +# 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.goals = compile diff --git a/src/it/release-without-profile-fork/pom.xml b/src/it/release-without-profile-fork/pom.xml new file mode 100644 index 00000000..529ceedb --- /dev/null +++ b/src/it/release-without-profile-fork/pom.xml @@ -0,0 +1,45 @@ + + + + + 4.0.0 + org.apache.maven.plugins.compiler.it + release-without-profile-fork + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + @project.version@ + + + 8 + 8 + 8 + true + + + + + + diff --git a/src/it/release-without-profile-fork/src/main/java/MyClass.java b/src/it/release-without-profile-fork/src/main/java/MyClass.java new file mode 100644 index 00000000..d4132bb2 --- /dev/null +++ b/src/it/release-without-profile-fork/src/main/java/MyClass.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +package foo; + +public class MyClass {} diff --git a/src/it/release-without-profile-fork/verify.groovy b/src/it/release-without-profile-fork/verify.groovy new file mode 100644 index 00000000..e563b3d7 --- /dev/null +++ b/src/it/release-without-profile-fork/verify.groovy @@ -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. + */ +def logFile = new File(basedir, 'build.log') +assert logFile.exists() +content = logFile.text + +// for jdk 8 we will have target and source +def jdkTarget = content.contains(' -source 8') && content.contains(' -target 8') && !content.contains(' --release 8') + +// for jdk9+ we will have release only +def jdkRelease = !content.contains(' -source 8') && !content.contains(' -target 8') && content.contains(' --release 8') + +assert (jdkTarget && !jdkRelease) || (!jdkTarget && jdkRelease) diff --git a/src/it/release-without-profile/invoker.properties b/src/it/release-without-profile/invoker.properties new file mode 100644 index 00000000..0659ac55 --- /dev/null +++ b/src/it/release-without-profile/invoker.properties @@ -0,0 +1,18 @@ +# 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.goals = compile diff --git a/src/it/release-without-profile/pom.xml b/src/it/release-without-profile/pom.xml new file mode 100644 index 00000000..ce58cab9 --- /dev/null +++ b/src/it/release-without-profile/pom.xml @@ -0,0 +1,44 @@ + + + + + 4.0.0 + org.apache.maven.plugins.compiler.it + release-without-profile + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + @project.version@ + + + 8 + 8 + 8 + + + + + + diff --git a/src/it/release-without-profile/src/main/java/MyClass.java b/src/it/release-without-profile/src/main/java/MyClass.java new file mode 100644 index 00000000..d4132bb2 --- /dev/null +++ b/src/it/release-without-profile/src/main/java/MyClass.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +package foo; + +public class MyClass {} diff --git a/src/it/release-without-profile/verify.groovy b/src/it/release-without-profile/verify.groovy new file mode 100644 index 00000000..e563b3d7 --- /dev/null +++ b/src/it/release-without-profile/verify.groovy @@ -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. + */ +def logFile = new File(basedir, 'build.log') +assert logFile.exists() +content = logFile.text + +// for jdk 8 we will have target and source +def jdkTarget = content.contains(' -source 8') && content.contains(' -target 8') && !content.contains(' --release 8') + +// for jdk9+ we will have release only +def jdkRelease = !content.contains(' -source 8') && !content.contains(' -target 8') && content.contains(' --release 8') + +assert (jdkTarget && !jdkRelease) || (!jdkTarget && jdkRelease) diff --git a/src/it/setup_annotation-verify-plugin/pom.xml b/src/it/setup_annotation-verify-plugin/pom.xml index f6ae99b3..67e23117 100644 --- a/src/it/setup_annotation-verify-plugin/pom.xml +++ b/src/it/setup_annotation-verify-plugin/pom.xml @@ -32,7 +32,7 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.3 + @version.maven-plugin-tools@ provided diff --git a/src/it/setup_jar_automodule/pom.xml b/src/it/setup_jar_automodule/pom.xml index b20e48b2..8cac6607 100644 --- a/src/it/setup_jar_automodule/pom.xml +++ b/src/it/setup_jar_automodule/pom.xml @@ -44,7 +44,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + @version.maven-jar-plugin@ diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java index 83fa7790..5f66e4ec 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java @@ -21,8 +21,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; @@ -138,6 +136,8 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { /** * Set to true to include debugging information in the compiled class files. + * @see javac -g + * @see #debuglevel */ @Parameter(property = "maven.compiler.debug", defaultValue = "true") private boolean debug = true; @@ -145,19 +145,23 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { /** * Set to true to generate metadata for reflection on method parameters. * @since 3.6.2 + * @see javac -parameters */ @Parameter(property = "maven.compiler.parameters", defaultValue = "false") private boolean parameters; /** - * Set to true to Enable preview language features of the java compiler + * Set to true to enable preview language features of the java compiler * @since 3.10.1 + * @see javac --enable-preview */ @Parameter(property = "maven.compiler.enablePreview", defaultValue = "false") private boolean enablePreview; /** * Set to true to show messages about what the compiler is doing. + * + * @see javac -verbose */ @Parameter(property = "maven.compiler.verbose", defaultValue = "false") private boolean verbose; @@ -183,39 +187,44 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { private boolean showWarnings; /** - *

The -source argument for the Java compiler.

+ *

The {@code -source} argument for the Java compiler.

* *

NOTE:

*

Since 3.8.0 the default value has changed from 1.5 to 1.6

*

Since 3.9.0 the default value has changed from 1.6 to 1.7

*

Since 3.11.0 the default value has changed from 1.7 to 1.8

+ * @see javac -source */ @Parameter(property = "maven.compiler.source", defaultValue = DEFAULT_SOURCE) protected String source; /** - *

The -target argument for the Java compiler.

+ *

The {@code -target} argument for the Java compiler.

* *

NOTE:

*

Since 3.8.0 the default value has changed from 1.5 to 1.6

*

Since 3.9.0 the default value has changed from 1.6 to 1.7

*

Since 3.11.0 the default value has changed from 1.7 to 1.8

+ * + * @see javac -target */ @Parameter(property = "maven.compiler.target", defaultValue = DEFAULT_TARGET) protected String target; /** - * The -release argument for the Java compiler, supported since Java9 + * The {@code -release} argument for the Java compiler, supported since Java9 * * @since 3.6 + * @see javac -release */ @Parameter(property = "maven.compiler.release") protected String release; /** - * The -encoding argument for the Java compiler. + * The {@code -encoding} argument for the Java compiler. * * @since 2.1 + * @see javac -encoding */ @Parameter(property = "encoding", defaultValue = "${project.build.sourceEncoding}") private String encoding; @@ -236,7 +245,10 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { /** * Version of the compiler to use, ex. "1.3", "1.5", if {@link #fork} is set to true. + * @deprecated This parameter is no longer evaluated by the underlying compilers, instead the actual + * version of the {@code javac} binary is automatically retrieved. */ + @Deprecated @Parameter(property = "maven.compiler.compilerVersion") private String compilerVersion; @@ -280,11 +292,16 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { *
    *
  • none - no annotation processing is performed.
  • *
  • only - only annotation processing is done, no compilation.
  • + *
  • full - annotation processing and compilation.
  • *
* + * full is the default. Starting with JDK 21, this option must be set explicitly. + * * @since 2.2 + * @see javac -proc + * @see javac Annotation Processing */ - @Parameter + @Parameter(property = "maven.compiler.proc") private String proc; /** @@ -294,6 +311,8 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { *

* * @since 2.2 + * @see javac -processor + * @see javac Annotation Processing */ @Parameter private String[] annotationProcessors; @@ -332,6 +351,9 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { * Note: Exclusions are supported from version 3.11.0. * * @since 3.5 + * @see javac -processorpath + * @see javac Annotation Processing + * */ @Parameter private List annotationProcessorPaths; @@ -343,7 +365,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { *

*

* This flag does not enable / disable the ability to resolve the version of annotation processor paths - * from dependency management section. It only influences the resolution o transitive dependencies of those + * from dependency management section. It only influences the resolution of transitive dependencies of those * top-level paths. *

* @@ -400,6 +422,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { * * * @since 3.1 + * @see javac -J */ @Parameter protected List compilerArgs; @@ -415,6 +438,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { *

* Note that {@code -J} options are only passed through if {@link #fork} is set to {@code true}. *

+ * @see javac -J */ @Parameter protected String compilerArgument; @@ -432,9 +456,10 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { * Keyword list to be appended to the -g command-line switch. Legal values are none or a * comma-separated list of the following keywords: lines, vars, and source. * If debug level is not specified, by default, nothing will be appended to -g. - * If debug is not turned on, this attribute will be ignored. + * If {@link #debug} is not turned on, this attribute will be ignored. * * @since 2.1 + * @see javac -G:[lines,vars,source] */ @Parameter(property = "maven.compiler.debuglevel") private String debuglevel; @@ -443,6 +468,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { * Keyword to be appended to the -implicit: command-line switch. * * @since 3.10.2 + * @see javac -implicit */ @Parameter(property = "maven.compiler.implicit") private String implicit; @@ -543,14 +569,28 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { private boolean skipMultiThreadWarning; /** - * compiler can now use javax.tools if available in your current jdk, you can disable this feature - * using -Dmaven.compiler.forceJavacCompilerUse=true or in the plugin configuration - * + * Legacy parameter name of {@link #forceLegacyJavacApi}. Only considered if {@link #forceLegacyJavacApi} is + * not set or {@code false}. * @since 3.0 + * @deprecated Use {@link #forceLegacyJavacApi} instead */ + @Deprecated @Parameter(defaultValue = "false", property = "maven.compiler.forceJavacCompilerUse") private boolean forceJavacCompilerUse; + /** + * The underlying compiler now uses {@code javax.tools} API + * if available in your current JDK. + * Set this to {@code true} to always use the legacy + * {@code com.sun.tools.javac} API instead. + *

+ * This only has an effect for {@link #compilerId} being {@code javac} and {@link #fork} being {@code false}. + * + * @since 3.13 + */ + @Parameter(defaultValue = "false", property = "maven.compiler.forceLegacyJavacApi") + private boolean forceLegacyJavacApi; + /** * @since 3.0 needed for storing the status for the incremental build support. */ @@ -680,7 +720,7 @@ public void execute() throws MojoExecutionException, CompilationFailureException try { compiler = compilerManager.getCompiler(compilerId); } catch (NoSuchCompilerException e) { - throw new MojoExecutionException("No such compiler '" + e.getCompilerId() + "'."); + throw new MojoExecutionException("No such compiler '" + e.getCompilerId() + "'.", e); } // -----------toolchains start here ---------------------------------- @@ -874,7 +914,7 @@ public void execute() throws MojoExecutionException, CompilationFailureException getLog().debug("CompilerReuseStrategy: " + compilerConfiguration.getCompilerReuseStrategy().getStrategy()); - compilerConfiguration.setForceJavacCompilerUse(forceJavacCompilerUse); + compilerConfiguration.setForceJavacCompilerUse(forceLegacyJavacApi || forceJavacCompilerUse); boolean canUpdateTarget; @@ -1037,7 +1077,7 @@ public void execute() throws MojoExecutionException, CompilationFailureException try { if (fork) { if (compilerConfiguration.getExecutable() != null) { - getLog().debug("Excutable: "); + getLog().debug("Executable: "); getLog().debug(" " + compilerConfiguration.getExecutable()); } } @@ -1457,31 +1497,13 @@ private String getMemoryValue(String setting) { return value; } - // TODO remove the part with ToolchainManager lookup once we depend on - // 3.0.9 (have it as prerequisite). Define as regular component field then. protected final Toolchain getToolchain() { Toolchain tc = null; if (jdkToolchain != null) { - // Maven 3.3.1 has plugin execution scoped Toolchain Support - try { - Method getToolchainsMethod = toolchainManager - .getClass() - .getMethod("getToolchains", MavenSession.class, String.class, Map.class); - - @SuppressWarnings("unchecked") - List tcs = - (List) getToolchainsMethod.invoke(toolchainManager, session, "jdk", jdkToolchain); - - if (tcs != null && !tcs.isEmpty()) { - tc = tcs.get(0); - } - } catch (NoSuchMethodException - | SecurityException - | IllegalAccessException - | IllegalArgumentException - | InvocationTargetException e) { - // ignore + List tcs = toolchainManager.getToolchains(session, "jdk", jdkToolchain); + if (tcs != null && !tcs.isEmpty()) { + tc = tcs.get(0); } } diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java index 9142f99d..52da7ca8 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java @@ -54,10 +54,14 @@ import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult; /** - * Compiles application sources + * Compiles application sources. + * By default uses the javac compiler + * of the JDK used to execute Maven. This can be overwritten through Toolchains + * or parameter {@link AbstractCompilerMojo#compilerId}. * * @author Jason van Zyl * @since 2.0 + * @see javac Command */ @Mojo( name = "compile", @@ -118,9 +122,7 @@ public class CompilerMojo extends AbstractCompilerMojo { private Set incrementalExcludes = new HashSet<>(); /** - *

* Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+ - *

* * @since 2.2 */ @@ -128,7 +130,7 @@ public class CompilerMojo extends AbstractCompilerMojo { private File generatedSourcesDirectory; /** - * Set this to 'true' to bypass compilation of main sources. Its use is NOT RECOMMENDED, but quite convenient on + * Set this to {@code true} to bypass compilation of main sources. Its use is NOT RECOMMENDED, but quite convenient on * occasion. */ @Parameter(property = "maven.main.skip") @@ -153,7 +155,8 @@ public class CompilerMojo extends AbstractCompilerMojo { private boolean multiReleaseOutput; /** - * when forking and debug activated the commandline used will be dumped in this file + * When both {@link AbstractCompilerMojo#fork} and {@link AbstractCompilerMojo#debug} are enabled the commandline arguments used + * will be dumped to this file. * @since 3.10.0 */ @Parameter(defaultValue = "javac") 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 43aab2f9..d2203771 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java @@ -50,9 +50,13 @@ /** * Compiles application test sources. + * By default uses the javac compiler + * of the JDK used to execute Maven. This can be overwritten through Toolchains + * or parameter {@link AbstractCompilerMojo#compilerId}. * * @author Jason van Zyl * @since 2.0 + * @see javac Command */ @Mojo( name = "testCompile", diff --git a/src/site/apt/examples/pass-compiler-arguments.apt.vm b/src/site/apt/examples/pass-compiler-arguments.apt.vm index d8b9197c..46057ff1 100644 --- a/src/site/apt/examples/pass-compiler-arguments.apt.vm +++ b/src/site/apt/examples/pass-compiler-arguments.apt.vm @@ -28,8 +28,8 @@ Pass Compiler Arguments - Sometimes, you need to pass other compiler arguments that are not handled by - the Compiler Plugin itself but is supported by the <<>> selected. + Sometimes, you need to pass compiler arguments that are not handled by + the Compiler Plugin itself but are supported by the <<>> selected. For such arguments, use the Compiler Plugin's <<>> parameter The following example passes compiler arguments to the <<>> compiler: diff --git a/src/site/apt/examples/set-compiler-release.apt.vm b/src/site/apt/examples/set-compiler-release.apt.vm index 51219e09..3befe702 100644 --- a/src/site/apt/examples/set-compiler-release.apt.vm +++ b/src/site/apt/examples/set-compiler-release.apt.vm @@ -85,7 +85,12 @@ Setting the <<<--release>>> of the Java Compiler The <<<--release>>> option is not supported using JDK 8. To enable a project that targets Java 8 to be built using JDK 8 and also JDK 9 or later requires the conditional usage of the - <<<--release>>> option. This may be done through the use of a profile: + <<<--release>>> option. + + Conditional parametrization is required for the Compiler Plugin version below <<<3.13.0>>> + or compilerId different that <<>>. + + This may be done through the use of a profile: +----- @@ -106,3 +111,32 @@ Setting the <<<--release>>> of the Java Compiler [...] +----- + + Since version <<<3.13.0>>> of the Compiler Plugin together with the default <<>> compilerId you don't need conditional parametrisation of <<>>. + The <<>> parameter will only be effective for Java 9 or above, otherwise the <<>> and <<>> will be passed to the compiler. + + So you can simply configure as: + ++----- + + [...] + + [...] + + + org.apache.maven.plugins + maven-compiler-plugin + ${project.version} + + 8 + 8 + 8 + + + + [...] + + [...] + ++----- + diff --git a/src/site/apt/non-javac-compilers.apt.vm b/src/site/apt/non-javac-compilers.apt.vm index b76d0e0e..95667bdb 100644 --- a/src/site/apt/non-javac-compilers.apt.vm +++ b/src/site/apt/non-javac-compilers.apt.vm @@ -31,22 +31,24 @@ Using Non-Javac Compilers Contrary to this plugin's name, the Compiler Plugin does not compile the sources of your project by itself. To compile, the Compiler Plugin uses - another class to compile them. The parameter <<>> determines - which class will be used. Currently, the Compiler Plugin is bundled with the - <<>> compiler artifact with artifactId <<>>, - which can be seen as one of the dependencies declared inside the Compiler - Plugin's POM. + another class to compile them. - {{{http://codehaus-plexus.github.io/plexus-compiler/}Plexus Compiler}} component + The parameter <<>> determines which class will be used. + + Currently, the Compiler Plugin is bundled with the <<>> compiler + with artifactId <<>> version <<${plexusCompilerVersion}>>, + which can be seen as one of the dependencies declared inside the Compiler Plugin's POM. + + {{{https://codehaus-plexus.github.io/plexus-compiler/}Plexus Compiler}} component has some other compiler Ids available under the groupId <<>>: - * <<>> with artifactId <<>>. + * <<>> with artifactId <<>> - <>: <<>> and <<>> - * <<>> with artifactId <<>>. + * <<>> with artifactId <<>> - <>: <<>> - * <<>> with artifactId <<>>. + * <<>> with artifactId <<>> - <>: <<>> and <<>> - * <<>> with artifactId <<>>. + * <<>> with artifactId <<>> - <>: <<>> [] @@ -74,7 +76,7 @@ Using Non-Javac Compilers org.codehaus.plexus plexus-compiler-csharp - 1.6 + ${plexusCompilerVersion}