File tree Expand file tree Collapse file tree 3 files changed +40
-6
lines changed
src/main/java/org/javamodularity/moduleplugin/tasks
test-project/greeter.provider/src/test/java/examples/greeter Expand file tree Collapse file tree 3 files changed +40
-6
lines changed 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 ) {
Original file line number Diff line number Diff line change 1+ package examples .greeter ;
2+
3+ import java .lang .module .ModuleReader ;
4+ import java .util .List ;
5+ import java .util .stream .Collectors ;
6+ import org .junit .jupiter .api .Test ;
7+
8+ import static org .junit .jupiter .api .Assertions .*;
9+
10+ class ModuleReaderTest {
11+ @ Test
12+ void testList () throws Exception {
13+ ModuleReader reader = ModuleReaderTest .class .getModule ()
14+ .getLayer ()
15+ .configuration ()
16+ .findModule ("greeter.provider" )
17+ .orElseThrow ()
18+ .reference ()
19+ .open ();
20+
21+ List <String > content = reader .list ().collect (Collectors .toList ());
22+
23+ assertFalse (content .isEmpty ());
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments