Skip to content

Commit 785089d

Browse files
authored
[MCOMPILER-488] dedicated option for implicit javac flag (#102)
* Use (local) plexus snapshot * [MCOMPILER-488] dedicated option for `implicit` javac flag Co-authored-by: Piotrek Żygieło <[email protected]>
1 parent cfea6eb commit 785089d

File tree

5 files changed

+107
-1
lines changed

5 files changed

+107
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ under the License.
6868
! The following property is used in the integration tests MCOMPILER-157
6969
-->
7070
<mavenPluginPluginVersion>3.5</mavenPluginPluginVersion>
71-
<plexusCompilerVersion>2.11.1</plexusCompilerVersion>
71+
<plexusCompilerVersion>2.11.2-SNAPSHOT</plexusCompilerVersion>
7272

7373
<groovyVersion>2.4.21</groovyVersion>
7474
<groovyEclipseCompilerVersion>3.7.0</groovyEclipseCompilerVersion>

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ public abstract class AbstractCompilerMojo
402402
@Parameter( property = "maven.compiler.debuglevel" )
403403
private String debuglevel;
404404

405+
/**
406+
* Keyword to be appended to the <code>-implicit:</code> command-line switch.
407+
*
408+
* @since 3.10.2
409+
*/
410+
@Parameter( property = "maven.compiler.implicit" )
411+
private String implicit;
412+
405413
/**
406414
*
407415
*/
@@ -686,6 +694,8 @@ public void execute()
686694

687695
compilerConfiguration.setDebugFileName( getDebugFileName() );
688696

697+
compilerConfiguration.setImplicitOption( implicit );
698+
689699
if ( debug && StringUtils.isNotEmpty( debuglevel ) )
690700
{
691701
String[] split = StringUtils.split( debuglevel, "," );
@@ -1910,4 +1920,9 @@ public void setRelease( String release )
19101920
this.release = release;
19111921
targetOrReleaseSet = true;
19121922
}
1923+
1924+
final String getImplicit()
1925+
{
1926+
return implicit;
1927+
}
19131928
}

src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ public void testCompilerArgs()
267267
assertEquals( Arrays.asList( "key1=value1","-Xlint","-my&special:param-with+chars/not>allowed_in_XML_element_names" ), compileMojo.compilerArgs );
268268
}
269269

270+
public void testImplicitFlagNone()
271+
throws Exception
272+
{
273+
CompilerMojo compileMojo = getCompilerMojo( "target/test-classes/unit/compiler-implicit-test/plugin-config-none.xml" );
274+
275+
assertEquals( "none", compileMojo.getImplicit() );
276+
}
277+
278+
public void testImplicitFlagNotSet()
279+
throws Exception
280+
{
281+
CompilerMojo compileMojo = getCompilerMojo( "target/test-classes/unit/compiler-implicit-test/plugin-config-not-set.xml" );
282+
283+
assertNull( compileMojo.getImplicit() );
284+
}
285+
270286
public void testOneOutputFileForAllInput2()
271287
throws Exception
272288
{
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
-->
19+
20+
<project>
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<configuration>
26+
<compileSourceRoots>
27+
<compileSourceRoot>${basedir}/target/test-classes/unit/compiler-implicit-test/src/main/java</compileSourceRoot>
28+
</compileSourceRoots>
29+
<compilerId>javac</compilerId>
30+
<debug>true</debug>
31+
<outputDirectory>${basedir}/target/test/unit/compiler-implicit-test/target/classes</outputDirectory>
32+
<buildDirectory>${basedir}/target/test/unit/compiler-implicit-test/target</buildDirectory>
33+
<implicit>none</implicit>
34+
</configuration>
35+
</plugin>
36+
</plugins>
37+
</build>
38+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
-->
19+
20+
<project>
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<configuration>
26+
<compileSourceRoots>
27+
<compileSourceRoot>${basedir}/target/test-classes/unit/compiler-implicit-test/src/main/java</compileSourceRoot>
28+
</compileSourceRoots>
29+
<compilerId>javac</compilerId>
30+
<debug>true</debug>
31+
<outputDirectory>${basedir}/target/test/unit/compiler-implicit-test/target/classes</outputDirectory>
32+
<buildDirectory>${basedir}/target/test/unit/compiler-implicit-test/target</buildDirectory>
33+
</configuration>
34+
</plugin>
35+
</plugins>
36+
</build>
37+
</project>

0 commit comments

Comments
 (0)