diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java index d5c69514cb281..96d74559b2e50 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java @@ -153,7 +153,9 @@ public boolean consume(ArgumentQueue args) { if (jarFilePathStr == null) { NativeImage.showError(requireValidJarFileMessage); } - handleJarFileArg(nativeImage.canonicalize(Paths.get(jarFilePathStr))); + final Path filePath = nativeImage.canonicalize(Paths.get(jarFilePathStr)); + nativeImage.setJarFilePath(filePath); + handleJarFileArg(filePath); nativeImage.setJarOptionMode(true); return true; case verboseOption: @@ -319,7 +321,6 @@ private void handleJarFileArg(Path filePath) { if (!NativeImage.processJarManifestMainAttributes(filePath, nativeImage::handleMainClassAttribute)) { NativeImage.showError("No manifest in " + filePath); } - nativeImage.addCustomImageClasspath(filePath); } @Override diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java index 4031fabb0a3e8..eab216a51f4cb 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java @@ -253,6 +253,7 @@ private static String oR(OptionKey option) { private boolean diagnostics = false; String diagnosticsDir; private boolean jarOptionMode = false; + private Path jarFilePath; private boolean dryRun = false; private String printFlagsOptionQuery = null; private String printFlagsWithExtraHelpOptionQuery = null; @@ -688,9 +689,18 @@ public void showVerboseMessage(String message) { @Override public boolean isExcluded(Path resourcePath, Path classpathEntry) { + showVerboseMessage(String.format("Attempt to check if resource %s in classpath entry %s should be excluded", resourcePath, classpathEntry)); return excludedConfigs.stream() - .filter(e -> e.jarPattern.matcher(classpathEntry.toString()).find()) - .anyMatch(e -> e.resourcePattern.matcher(resourcePath.toString()).find()); + .filter(e -> regexMatch(classpathEntry, e.jarPattern, "Classpath entry")) + .anyMatch(e -> regexMatch(resourcePath, e.resourcePattern, "Resource path")); + } + + private boolean regexMatch(Path path, Pattern pattern, String prefix) { + final boolean matches = pattern.matcher(path.toString()).find(); + if (verbose) { + showVerboseMessage(String.format("%s %s %s match pattern %s", prefix, path, matches ? "does" : "doesn't", pattern)); + } + return matches; } } @@ -1111,6 +1121,10 @@ private int completeImageBuild() { addPlainImageBuilderArg(NativeImage.oR + enablePrintFlagsWithExtraHelp + "=" + printFlagsWithExtraHelpOptionQuery); } + if (jarOptionMode) { + addCustomImageClasspath(jarFilePath); + } + if (shouldAddCWDToCP()) { addImageClasspath(Paths.get(".")); } @@ -1778,6 +1792,10 @@ void setDiagnostics(boolean val) { } } + void setJarFilePath(Path jarFilePath) { + this.jarFilePath = jarFilePath; + } + void setJarOptionMode(boolean val) { jarOptionMode = val; }