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 1212import org .javamodularity .moduleplugin .extensions .RunModuleOptions ;
1313import org .javamodularity .moduleplugin .internal .TaskOption ;
1414
15+ import java .nio .file .Files ;
1516import java .util .ArrayList ;
1617import java .util .List ;
1718import java .util .stream .Collectors ;
@@ -53,7 +54,10 @@ private List<String> buildJavaExecJvmArgs() {
5354 .collect (Collectors .toList ()).toArray ());
5455 var patchModuleContainer = PatchModuleContainer .copyOf (
5556 helper ().modularityExtension ().optionContainer ().getPatchModuleContainer ());
56- patchModuleContainer .addDir (moduleName , helper ().mainSourceSet ().getOutput ().getResourcesDir ().getAbsolutePath ());
57+ var resourceDir = helper ().mainSourceSet ().getOutput ().getResourcesDir ();
58+ if (resourceDir != null && Files .isDirectory (resourceDir .toPath ())) {
59+ patchModuleContainer .addDir (moduleName , resourceDir .getAbsolutePath ());
60+ }
5761 patchModuleContainer .buildModulePathOption (filteredClasspath ).ifPresent (option -> option .mutateArgs (jvmArgs ));
5862 patchModuleContainer .mutator (filteredClasspath ).mutateArgs (jvmArgs );
5963
Original file line number Diff line number Diff line change @@ -104,12 +104,17 @@ private Stream<Path> buildPatchModulePathStream() {
104104 sourceSets .add (mainSourceSet );
105105 sourceSets .addAll (classesSourceSets );
106106
107- Stream <File > classesFileStream = classesSourceSets .stream ()
108- .flatMap (sourceSet -> sourceSet .getOutput ().getClassesDirs ().getFiles ().stream ());
109- Stream <File > resourceFileStream = sourceSets .stream ()
110- .map (sourceSet -> sourceSet .getOutput ().getResourcesDir ());
107+ Stream <Path > classesFileStream = classesSourceSets .stream ()
108+ .flatMap (sourceSet -> sourceSet .getOutput ().getClassesDirs ().getFiles ().stream ())
109+ .map (File ::toPath );
111110
112- return Stream .concat (classesFileStream , resourceFileStream ).map (File ::toPath );
111+ Stream <Path > resourceFileStream = sourceSets .stream ()
112+ .map (sourceSet -> sourceSet .getOutput ().getResourcesDir ())
113+ .filter (Objects ::nonNull )
114+ .map (File ::toPath )
115+ .filter (Files ::isDirectory );
116+
117+ return Stream .concat (classesFileStream , resourceFileStream );
113118 }
114119
115120 private TaskOption buildAddReadsOption (TestEngine testEngine ) {
You can’t perform that action at this time.
0 commit comments