Skip to content

Commit 575f6a7

Browse files
committed
Enhance the lookup for jmods folder. We now use a recursive folder search seeded at the JAVA_HOME directory to look for a folder.
Signed-off-by: Rahul Krishna <[email protected]>
1 parent 5355c2f commit 575f6a7

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

src/main/java/com/ibm/cldk/utils/ScopeUtils.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
import java.io.ByteArrayInputStream;
2222
import java.io.IOException;
2323
import java.nio.charset.StandardCharsets;
24+
import java.nio.file.FileVisitOption;
2425
import java.nio.file.Files;
2526
import java.nio.file.Path;
2627
import java.nio.file.Paths;
2728
import java.util.List;
2829
import java.util.Objects;
2930
import java.util.UUID;
3031
import java.util.jar.JarFile;
32+
import java.util.stream.Stream;
3133

3234
import org.apache.commons.io.FileUtils;
3335

@@ -70,7 +72,7 @@ public static AnalysisScope createScope(String projectPath, String applicationDe
7072
throw new RuntimeException("JAVA_HOME is not set.");
7173
}
7274

73-
String[] stdlibs = Files.walk(Paths.get(System.getenv("JAVA_HOME"), "jmods"))
75+
String[] stdlibs = Files.walk(getJmodsPath())
7476
.filter(path -> path.toString().endsWith(".jmod"))
7577
.map(path -> path.toAbsolutePath().toString())
7678
.toArray(String[]::new);
@@ -130,6 +132,19 @@ public static AnalysisScope createScope(String projectPath, String applicationDe
130132
return scope;
131133
}
132134

135+
private static Path getJmodsPath() {
136+
try {
137+
try (Stream<Path> paths = Files.walk(Path.of(System.getenv("JAVA_HOME")), Integer.MAX_VALUE, FileVisitOption.FOLLOW_LINKS)) {
138+
return paths
139+
.filter(path -> path.getFileName().toString().equals("jmods"))
140+
.findFirst()
141+
.orElseThrow(() -> new RuntimeException("jmods directory not found in " + System.getenv("JAVA_HOME")));
142+
}
143+
} catch (IOException e) {
144+
throw new RuntimeException("Error searching for jmods directory", e);
145+
}
146+
}
147+
133148
private static AnalysisScope addDefaultExclusions(AnalysisScope scope)
134149
throws IOException {
135150
Log.info("Add exclusions to scope.");

src/test/resources/test-applications/no-mvnw-test/target/classes/META-INF/microprofile-config.properties

Whitespace-only changes.

src/test/resources/test-applications/no-mvnw-test/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/test/resources/test-applications/no-mvnw-test/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)