Skip to content

Commit

Permalink
[MCOMPILER-579] allow module-version configuration (#273)
Browse files Browse the repository at this point in the history
* MCOMPILER-579 allow module-version configuration

* Rename property `moduleVersion` to `maven.compiler.moduleVersion`

* Move moduleVersion to CompilerMojo

---------

Co-authored-by: Slawomir Jaranowski <[email protected]>
  • Loading branch information
mguillem and slawekjaranowski authored Feb 15, 2025
1 parent f7c3c5f commit 09dce4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ under the License.
</parent>

<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.1-SNAPSHOT</version>
<version>3.14.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

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

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-module-version">javac --module-version</a>
* @since 3.14.0
*/
@Parameter(property = "maven.compiler.moduleVersion", defaultValue = "${project.version}")
private String moduleVersion;

final LocationManager locationManager = new LocationManager();

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

compilerArgs.add("--module-version");
compilerArgs.add(getProject().getVersion());
compilerArgs.add(moduleVersion);

} catch (IOException e) {
getLog().warn(e.getMessage());
Expand Down

0 comments on commit 09dce4e

Please sign in to comment.