File tree Expand file tree Collapse file tree
src/main/java/org/javamodularity/moduleplugin/tasks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111import org .javamodularity .moduleplugin .extensions .PatchModuleContainer ;
1212import org .javamodularity .moduleplugin .internal .MutatorHelper ;
1313
14+ import java .io .File ;
1415import java .util .ArrayList ;
1516import java .util .List ;
17+ import java .util .stream .Collectors ;
1618
1719class CompileJavaTaskMutator {
1820 private static final Logger LOGGER = Logging .getLogger (CompileJavaTaskMutator .class );
@@ -62,10 +64,15 @@ private List<String> buildCompilerArgs(JavaCompile javaCompile) {
6264 .map (AbstractCompile ::getDestinationDir )
6365 .forEach (dir -> patchModuleContainer .addDir (moduleName , dir .getAbsolutePath ()));
6466
67+ // Keep only valid module-path entries (https://github.com/java9-modularity/gradle-modules-plugin/issues/190)
68+ FileCollection filteredClasspath = project .files (compileJavaClasspath .getFiles ().stream ()
69+ .filter (f -> f .getName ().endsWith (".jar" ) || f .getName ().endsWith (".jmod" ))
70+ .collect (Collectors .toList ()).toArray ());
71+
6572 var compilerArgs = new ArrayList <>(javaCompile .getOptions ().getCompilerArgs ());
66- patchModuleContainer .buildModulePathOption (compileJavaClasspath )
73+ patchModuleContainer .buildModulePathOption (filteredClasspath )
6774 .ifPresent (option -> option .mutateArgs (compilerArgs ));
68- patchModuleContainer .mutator (compileJavaClasspath ).mutateArgs (compilerArgs );
75+ patchModuleContainer .mutator (filteredClasspath ).mutateArgs (compilerArgs );
6976
7077 moduleOptions .mutateArgs (compilerArgs );
7178 MutatorHelper .configureModuleVersion (helper (), compilerArgs );
Original file line number Diff line number Diff line change @@ -37,15 +37,6 @@ public void configureCompileJava() {
3737 }
3838
3939 private void configureCompileJava (JavaCompile compileJava ) {
40- project .getConfigurations ().stream ()
41- .flatMap (configuration -> configuration .getDependencies ().stream ())
42- .filter (dependency -> dependency instanceof ProjectDependency )
43- .map (dependency -> ((ProjectDependency ) dependency ).getDependencyProject ().getTasks ())
44- .map (tasks -> tasks .findByName (CompileModuleOptions .COMPILE_MODULE_INFO_TASK_NAME ))
45- .filter (Objects ::nonNull );
46-
47-
48-
4940 var moduleOptions = compileJava .getExtensions ().create ("moduleOptions" , CompileModuleOptions .class , project );
5041 project .afterEvaluate (p -> {
5142 adjustMainClass (compileJava );
You can’t perform that action at this time.
0 commit comments