Skip to content

Commit

Permalink
#150 Support --process-module-path
Browse files Browse the repository at this point in the history
  • Loading branch information
rfscholte committed Sep 11, 2021
1 parent aabfe38 commit 93fd2b2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ public class CompilerConfiguration
*/
private List<String> processorPathEntries;

/**
* --processor-module-path parameter in jdk 9+. If specified, annotation processors are only searched in the processor
* path. Otherwise they are searched in the modulepath.
*/
private List<String> processorModulePathEntries;

/**
* default value {@link CompilerReuseStrategy#ReuseCreated}
*
Expand Down Expand Up @@ -684,6 +690,26 @@ public void setProcessorPathEntries(List<String> processorPathEntries) {
this.processorPathEntries = processorPathEntries;
}


public void addProcessorModulePathEntry(String entry) {
if ( processorModulePathEntries == null ) {
processorModulePathEntries = new LinkedList<>();
}

processorModulePathEntries.add( entry );
}

public List<String> getProcessorModulePathEntries()
{
return processorModulePathEntries;
}

public void setProcessorModulePathEntries( List<String> processorModulePathEntries )
{
this.processorModulePathEntries = processorModulePathEntries;
}


public CompilerReuseStrategy getCompilerReuseStrategy()
{
return compilerReuseStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ public CompilerResult performCompile( CompilerConfiguration config )
//now add jdk 1.6 annotation processing related parameters
String[] annotationProcessors = config.getAnnotationProcessors();
List<String> processorPathEntries = config.getProcessorPathEntries();
if ( ( annotationProcessors != null && annotationProcessors.length > 0 ) || ( processorPathEntries != null
&& processorPathEntries.size() > 0 ) )
List<String> processorModulePathEntries = config.getProcessorModulePathEntries();

if ( ( annotationProcessors != null && annotationProcessors.length > 0 )
|| ( processorPathEntries != null && processorPathEntries.size() > 0 )
|| ( processorModulePathEntries != null && processorModulePathEntries.size() > 0 ) )
{
if ( annotationProcessors != null && annotationProcessors.length > 0 )
{
Expand All @@ -201,6 +204,12 @@ public CompilerResult performCompile( CompilerConfiguration config )
args.add( "-processorpath" );
args.add( getPathString( processorPathEntries ) );
}

if ( processorModulePathEntries != null && processorModulePathEntries.size() > 0 )
{
args.add( "-processorpath" );
args.add( getPathString( processorModulePathEntries ) );
}

if ( config.getProc() != null )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,22 +289,18 @@ public static String[] buildCompilerArguments( CompilerConfiguration config, Str
}
args.add( buffer.toString() );
}
if ( config.getProcessorPathEntries() != null && !config.getProcessorPathEntries().isEmpty() ) {

if(!isPreJava9(config) && Arrays.asList(sourceFiles).contains("module-info.java")){
args.add( "--processor-module-path" );

} else {
args.add( "-processorpath" );

}
if ( config.getProcessorPathEntries() != null && !config.getProcessorPathEntries().isEmpty() )
{
args.add( "-processorpath" );
args.add( getPathString( config.getProcessorPathEntries() ) );
}

if ( config.getProcessorModulePathEntries() != null && !config.getProcessorModulePathEntries().isEmpty() )
{
args.add( "--processor-module-path" );
args.add( getPathString( config.getProcessorModulePathEntries() ) );
}
}



if ( config.isOptimize() )
{
args.add( "-O" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public void testModulePathAnnotations() throws Exception
expectedArguments.add( "/repo/a/b/1.0/b-1.0.jar" + File.pathSeparator +
"/repo/c/d/1.0/d-1.0.jar" + File.pathSeparator );

compilerConfiguration.setProcessorPathEntries(Arrays.asList("/repo/a/b/1.0/annotations-1.0.jar",
compilerConfiguration.setProcessorModulePathEntries(Arrays.asList("/repo/a/b/1.0/annotations-1.0.jar",
"/repo/f/a/1.0/annotations-4.0.jar"));
expectedArguments.add( "--processor-module-path" );
expectedArguments.add("/repo/a/b/1.0/annotations-1.0.jar" + File.pathSeparator +
Expand Down

0 comments on commit 93fd2b2

Please sign in to comment.