Skip to content

Commit d87e67a

Browse files
committed
Only add class folders that exist to the '--patch-module' argument
1 parent ad52712 commit d87e67a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/org/gradlex/javamodule/testing/internal/provider/WhiteboxTestRuntimeArgumentProvider.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,22 @@ public Iterable<String> asArguments() {
105105
}
106106
}
107107

108+
String testClassesPath = testClassesFolders.get().getAsFile().getPath();
109+
String resourcesUnderTestPath = toAppendablePathEntry(resourcesUnderTest);
110+
String testResourcesPath = toAppendablePathEntry(testResources);
111+
108112
// Patch into Module located in the 'main' classes folder: test classes, resources, test resources
109113
args.add("--patch-module");
110-
args.add(moduleName + "=" +
111-
testClassesFolders.get().getAsFile().getPath() + File.pathSeparator +
112-
resourcesUnderTest.getPath() + File.pathSeparator +
113-
testResources.getPath());
114+
args.add(moduleName + "=" + testClassesPath + resourcesUnderTestPath + testResourcesPath);
114115

115116
return args;
116117
}
118+
119+
private String toAppendablePathEntry(File folder) {
120+
if (folder.exists()) {
121+
return File.pathSeparator + folder.getPath();
122+
} else {
123+
return "";
124+
}
125+
}
117126
}

0 commit comments

Comments
 (0)