Skip to content

Add the ability to specify --module-version argument for Java 9+ #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public class CompilerConfiguration

private String sourceEncoding;

/**
* value of --module-version parameter in java 9+
*/
private String moduleVersion;

private Collection<Map.Entry<String,String>> customCompilerArguments = new ArrayList<Map.Entry<String,String>>();

private boolean fork;
Expand Down Expand Up @@ -404,6 +409,16 @@ public void setSourceEncoding( String sourceEncoding )
this.sourceEncoding = sourceEncoding;
}

public String getModuleVersion()
{
return moduleVersion;
}

public void setModuleVersion( String moduleVersion )
{
this.moduleVersion = moduleVersion;
}

public void addCompilerCustomArgument( String customArgument, String value )
{
customCompilerArguments.add( new AbstractMap.SimpleImmutableEntry<String, String>( customArgument, value ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ else if ( !suppressSource( config ) )
args.add( config.getSourceEncoding() );
}

if ( !StringUtils.isEmpty( config.getModuleVersion() ) )
{
args.add( "--module-version" );
args.add( config.getModuleVersion() );
}

for ( Map.Entry<String, String> entry : config.getCustomCompilerArgumentsEntries() )
{
String key = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,31 @@ public void testModulePath() throws Exception
internalTest( compilerConfiguration, expectedArguments );
}

public void testModuleVersion()
{
List<String> expectedArguments = new ArrayList<String>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

// outputLocation
compilerConfiguration.setOutputLocation( "/output" );
expectedArguments.add( "-d" );
expectedArguments.add( new File( "/output" ).getAbsolutePath() );

// default source + target
expectedArguments.add( "-target" );
expectedArguments.add( "1.1" );
expectedArguments.add( "-source" );
expectedArguments.add( "1.3" );

// module version
compilerConfiguration.setModuleVersion( "1.2.0-SNAPSHOT" );
expectedArguments.add( "--module-version" );
expectedArguments.add( "1.2.0-SNAPSHOT" );

internalTest( compilerConfiguration, expectedArguments );
}

public void testReleaseVersion()
{
List<String> expectedArguments = new ArrayList<String>();
Expand Down