Skip to content

Commit

Permalink
[MCOMPILER-488] dedicated option for implicit javac flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo committed Mar 17, 2022
1 parent 0e8e916 commit 1758471
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ public abstract class AbstractCompilerMojo
@Parameter( property = "maven.compiler.debuglevel" )
private String debuglevel;

/**
* Keyword to be appended to the <code>-implicit:</code> command-line switch.
*
* @since 3.10.2
*/
@Parameter( property = "maven.compiler.implicit" )
private String implicit;

/**
*
*/
Expand Down Expand Up @@ -686,6 +694,8 @@ public void execute()

compilerConfiguration.setDebugFileName( getDebugFileName() );

compilerConfiguration.setImplicitOption( implicit );

if ( debug && StringUtils.isNotEmpty( debuglevel ) )
{
String[] split = StringUtils.split( debuglevel, "," );
Expand Down Expand Up @@ -1910,4 +1920,9 @@ public void setRelease( String release )
this.release = release;
targetOrReleaseSet = true;
}

final String getImplicit()
{
return implicit;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ public void testCompilerArgs()
assertEquals( Arrays.asList( "key1=value1","-Xlint","-my&special:param-with+chars/not>allowed_in_XML_element_names" ), compileMojo.compilerArgs );
}

public void testImplicitFlagNone()
throws Exception
{
CompilerMojo compileMojo = getCompilerMojo( "target/test-classes/unit/compiler-implicit-test/plugin-config-none.xml" );

assertEquals( "none", compileMojo.getImplicit() );
}

public void testImplicitFlagNotSet()
throws Exception
{
CompilerMojo compileMojo = getCompilerMojo( "target/test-classes/unit/compiler-implicit-test/plugin-config-not-set.xml" );

assertNull( compileMojo.getImplicit() );
}

public void testOneOutputFileForAllInput2()
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compileSourceRoots>
<compileSourceRoot>${basedir}/target/test-classes/unit/compiler-implicit-test/src/main/java</compileSourceRoot>
</compileSourceRoots>
<compilerId>javac</compilerId>
<debug>true</debug>
<outputDirectory>${basedir}/target/test/unit/compiler-implicit-test/target/classes</outputDirectory>
<buildDirectory>${basedir}/target/test/unit/compiler-implicit-test/target</buildDirectory>
<implicit>none</implicit>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compileSourceRoots>
<compileSourceRoot>${basedir}/target/test-classes/unit/compiler-implicit-test/src/main/java</compileSourceRoot>
</compileSourceRoots>
<compilerId>javac</compilerId>
<debug>true</debug>
<outputDirectory>${basedir}/target/test/unit/compiler-implicit-test/target/classes</outputDirectory>
<buildDirectory>${basedir}/target/test/unit/compiler-implicit-test/target</buildDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 1758471

Please sign in to comment.