File tree 1 file changed +14
-3
lines changed
src/main/java/org/apache/maven/plugin/compiler 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 {
172
172
@ Parameter (property = "maven.compiler.moduleVersion" , defaultValue = "${project.version}" )
173
173
private String moduleVersion ;
174
174
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
+
175
185
final LocationManager locationManager = new LocationManager ();
176
186
177
187
private List <String > classpathElements ;
@@ -311,9 +321,10 @@ protected void preparePaths(Set<File> sourceFiles) {
311
321
modulepathElements .add (file .getPath ());
312
322
}
313
323
314
- compilerArgs .add ("--module-version" );
315
- compilerArgs .add (moduleVersion );
316
-
324
+ if (useModuleVersion ) {
325
+ compilerArgs .add ("--module-version" );
326
+ compilerArgs .add (moduleVersion );
327
+ }
317
328
} catch (IOException e ) {
318
329
getLog ().warn (e .getMessage ());
319
330
}
You can’t perform that action at this time.
0 commit comments