File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
src/main/java/org/apache/maven/plugin/compiler Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,16 @@ public class CompilerMojo extends AbstractCompilerMojo {
172172 @ Parameter (property = "maven.compiler.moduleVersion" , defaultValue = "${project.version}" )
173173 private String moduleVersion ;
174174
175+ /**
176+ * Use the {@code --module-version} argument for the Java compiler.
177+ * This is ignored if not applicable, e.g., in non-modular projects.
178+ *
179+ * @see <a href="https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-module-version">javac --module-version</a>
180+ * @since 3.15.0
181+ */
182+ @ Parameter (property = "maven.compiler.useModuleVersion" , defaultValue = "true" )
183+ private boolean useModuleVersion ;
184+
175185 final LocationManager locationManager = new LocationManager ();
176186
177187 private List <String > classpathElements ;
@@ -311,9 +321,10 @@ protected void preparePaths(Set<File> sourceFiles) {
311321 modulepathElements .add (file .getPath ());
312322 }
313323
314- compilerArgs .add ("--module-version" );
315- compilerArgs .add (moduleVersion );
316-
324+ if (useModuleVersion ) {
325+ compilerArgs .add ("--module-version" );
326+ compilerArgs .add (moduleVersion );
327+ }
317328 } catch (IOException e ) {
318329 getLog ().warn (e .getMessage ());
319330 }
You can’t perform that action at this time.
0 commit comments