Skip to content

Commit 09dce4e

Browse files
[MCOMPILER-579] allow module-version configuration (#273)
* MCOMPILER-579 allow module-version configuration * Rename property `moduleVersion` to `maven.compiler.moduleVersion` * Move moduleVersion to CompilerMojo --------- Co-authored-by: Slawomir Jaranowski <[email protected]>
1 parent f7c3c5f commit 09dce4e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ under the License.
2828
</parent>
2929

3030
<artifactId>maven-compiler-plugin</artifactId>
31-
<version>3.13.1-SNAPSHOT</version>
31+
<version>3.14.0-SNAPSHOT</version>
3232
<packaging>maven-plugin</packaging>
3333

3434
<name>Apache Maven Compiler Plugin</name>
@@ -76,7 +76,7 @@ under the License.
7676
<plexus-java.version>1.4.0</plexus-java.version>
7777
<javaVersion>8</javaVersion>
7878
<maven.it.failure.ignore>false</maven.it.failure.ignore>
79-
<project.build.outputTimestamp>2024-03-15T07:28:09Z</project.build.outputTimestamp>
79+
<project.build.outputTimestamp>2025-02-13T18:15:32Z</project.build.outputTimestamp>
8080
<invoker.junitPackageName>org.apache.maven.plugins.compiler.its</invoker.junitPackageName>
8181
</properties>
8282

src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ public class CompilerMojo extends AbstractCompilerMojo {
162162
@Parameter(defaultValue = "javac")
163163
private String debugFileName;
164164

165+
/**
166+
* The {@code --module-version} argument for the Java compiler.
167+
* This is ignored if not applicable, e.g., in non-modular projects.
168+
*
169+
* @see <a href="https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-module-version">javac --module-version</a>
170+
* @since 3.14.0
171+
*/
172+
@Parameter(property = "maven.compiler.moduleVersion", defaultValue = "${project.version}")
173+
private String moduleVersion;
174+
165175
final LocationManager locationManager = new LocationManager();
166176

167177
private List<String> classpathElements;
@@ -302,7 +312,7 @@ protected void preparePaths(Set<File> sourceFiles) {
302312
}
303313

304314
compilerArgs.add("--module-version");
305-
compilerArgs.add(getProject().getVersion());
315+
compilerArgs.add(moduleVersion);
306316

307317
} catch (IOException e) {
308318
getLog().warn(e.getMessage());

0 commit comments

Comments
 (0)