Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

[MCOMPILER-178] add List parameter compilerArgs #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -233,10 +233,28 @@ public abstract class AbstractCompilerMojo
* </pre>
*
* @since 2.0.1
* @deprecated use {@link #compilerArgs} instead.
*/
@Parameter
@Deprecated
protected Map<String, String> compilerArguments;

/**
* <p>
* Sets the arguments to be passed to the compiler if {@link #fork} is set to <code>true</code>.
* Example:
* <pre>
* &lt;compilerArgs&gt;
* &lt;arg&gt;-Xmaxerrs=1000&lt;/arg&gt;
* &lt;arg&gt;-Xlint&lt;/arg&gt;
* &lt;/compilerArgs&gt;
* </pre>
*
* @since 3.1
*/
@Parameter
protected List<String> compilerArgs;

/**
* <p>
* Sets the unformatted single argument string to be passed to the compiler if {@link #fork} is set to <code>true</code>.
Expand Down Expand Up @@ -489,7 +507,7 @@ public void execute()

String effectiveCompilerArgument = getCompilerArgument();

if ( ( effectiveCompilerArguments != null ) || ( effectiveCompilerArgument != null ) )
if ( ( effectiveCompilerArguments != null ) || ( effectiveCompilerArgument != null ) || ( compilerArgs != null ) )
{
LinkedHashMap<String, String> cplrArgsCopy = new LinkedHashMap<String, String>();
if ( effectiveCompilerArguments != null )
Expand Down Expand Up @@ -517,6 +535,13 @@ public void execute()
{
cplrArgsCopy.put( effectiveCompilerArgument, null );
}
if ( compilerArgs != null )
{
for ( String arg : compilerArgs )
{
cplrArgsCopy.put( arg, null );
}
}
compilerConfiguration.setCustomCompilerArguments( cplrArgsCopy );
}

Expand Down
Expand Up @@ -32,6 +32,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -205,6 +206,7 @@ public void testCompilerArgs()

File testClass = new File( compileMojo.getOutputDirectory(), "compiled.class" );
assertTrue( testClass.exists() );
assertEquals( Arrays.asList( "key1=value1","-Xlint","-my&special:param-with+chars/not>allowed_in_XML_element_names" ), compileMojo.compilerArgs );
}

public void testOneOutputFileForAllInput2()
Expand Down
Expand Up @@ -36,6 +36,11 @@
<param2>value2</param2>
</compilerArgument>
</compilerArguments>
<compilerArgs>
<arg>key1=value1</arg>
<arg>-Xlint</arg>
<arg><![CDATA[-my&special:param-with+chars/not>allowed_in_XML_element_names]]></arg>
</compilerArgs>
<compilerArgument>param value</compilerArgument>
</configuration>
</plugin>
Expand Down