@@ -99,6 +99,15 @@ public abstract class ScalaMojoSupport extends AbstractMojo {
99
99
@ Parameter (property = "addScalacArgs" )
100
100
private String addScalacArgs ;
101
101
102
+ /** The -target argument for the Scala compiler. */
103
+ @ Parameter (property = "scala.compiler.target" )
104
+ protected String scalacTarget ;
105
+
106
+ /** The -release argument for the Scala compiler, supported since scala 2.13. */
107
+ @ Parameter (property = "scala.compiler.release" )
108
+ protected String scalacRelease ;
109
+
110
+
102
111
/** override the className (FQN) of the scala tool */
103
112
@ Parameter (required = false , property = "maven.scala.className" )
104
113
protected String scalaClassName ;
@@ -154,6 +163,10 @@ public abstract class ScalaMojoSupport extends AbstractMojo {
154
163
@ Parameter (property = "maven.compiler.target" )
155
164
protected String target ;
156
165
166
+ /** The --release argument for the Java compiler (when using incremental compiler), supported since Java9. */
167
+ @ Parameter (property = "maven.compiler.release" )
168
+ protected String release ;
169
+
157
170
/** The -encoding argument for the Java compiler. (when using incremental compiler). */
158
171
@ Parameter (property = "project.build.sourceEncoding" , defaultValue = "UTF-8" )
159
172
protected String encoding ;
@@ -577,6 +590,15 @@ protected List<String> getScalaOptions() throws Exception {
577
590
Collections .addAll (options , StringUtils .split (addScalacArgs , "|" ));
578
591
}
579
592
options .addAll (getCompilerPluginOptions ());
593
+
594
+ if (scalacTarget != null && !scalacTarget .isEmpty ()) {
595
+ options .add ("-target:" + scalacTarget );
596
+ }
597
+ if (scalacRelease != null && !scalacRelease .isEmpty ()) {
598
+ options .add ("-release" );
599
+ options .add (scalacRelease );
600
+ }
601
+
580
602
return options ;
581
603
}
582
604
@@ -591,13 +613,18 @@ protected List<String> getJavacOptions() {
591
613
if (javacGenerateDebugSymbols ) {
592
614
options .add ("-g" );
593
615
}
594
- if (target != null && !target .isEmpty ()) {
595
- options .add ("-target" );
596
- options .add (target );
597
- }
598
- if (source != null && !source .isEmpty ()) {
599
- options .add ("-source" );
600
- options .add (source );
616
+ if (release != null && !release .isEmpty ()) {
617
+ options .add ("--release" );
618
+ options .add (release );
619
+ } else {
620
+ if (target != null && !target .isEmpty ()) {
621
+ options .add ("-target" );
622
+ options .add (target );
623
+ }
624
+ if (source != null && !source .isEmpty ()) {
625
+ options .add ("-source" );
626
+ options .add (source );
627
+ }
601
628
}
602
629
if (encoding != null ) {
603
630
options .add ("-encoding" );
0 commit comments