diff --git a/pom.xml b/pom.xml index 5a83a207c..ea7d1ad3c 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-compiler-plugin - 3.13.1-SNAPSHOT + 3.14.0-SNAPSHOT maven-plugin Apache Maven Compiler Plugin @@ -76,7 +76,7 @@ under the License. 1.2.0 8 false - 2024-03-15T07:28:09Z + 2025-02-13T18:15:32Z org.apache.maven.plugins.compiler.its 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 52da7ca8d..cd273951a 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java @@ -162,6 +162,16 @@ public class CompilerMojo extends AbstractCompilerMojo { @Parameter(defaultValue = "javac") private String debugFileName; + /** + * The {@code --module-version} argument for the Java compiler. + * This is ignored if not applicable, e.g., in non-modular projects. + * + * @see javac --module-version + * @since 3.14.0 + */ + @Parameter(property = "maven.compiler.moduleVersion", defaultValue = "${project.version}") + private String moduleVersion; + final LocationManager locationManager = new LocationManager(); private List classpathElements; @@ -302,7 +312,7 @@ protected void preparePaths(Set sourceFiles) { } compilerArgs.add("--module-version"); - compilerArgs.add(getProject().getVersion()); + compilerArgs.add(moduleVersion); } catch (IOException e) { getLog().warn(e.getMessage());