Fix reachability argfile format
Update the argfile to a format that actually works when passed to the `native-image` command. See gh-32738
This commit is contained in:
@@ -369,15 +369,14 @@ class BootZipCopyAction implements CopyAction {
|
||||
}
|
||||
}
|
||||
}
|
||||
// https://docs.oracle.com/en/java/javase/18/docs/specs/man/java.html#java-command-line-argument-files
|
||||
if (excludes != null) {
|
||||
List<String> args = new ArrayList<>();
|
||||
for (String exclude : excludes) {
|
||||
int lastSlash = exclude.lastIndexOf('/');
|
||||
String jar = (lastSlash != -1) ? exclude.substring(lastSlash + 1) : exclude;
|
||||
args.add("--exclude-config");
|
||||
args.add("\"" + Pattern.quote(jar).replace("\\", "\\\\") + "\"");
|
||||
args.add("\"^/META-INF/native-image/.*\"");
|
||||
args.add(Pattern.quote(jar));
|
||||
args.add("^/META-INF/native-image/.*");
|
||||
}
|
||||
ZipEntryContentWriter writer = ZipEntryContentWriter.fromLines(BootZipCopyAction.this.encoding, args);
|
||||
writeEntry("META-INF/native-image/argfile", writer, true);
|
||||
|
||||
@@ -189,8 +189,8 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
void nativeImageArgFileWithExcludesIsWritten() throws IOException {
|
||||
try (JarFile jarFile = new JarFile(createLayeredJar(true))) {
|
||||
assertThat(entryLines(jarFile, "META-INF/native-image/argfile")).containsExactly("--exclude-config",
|
||||
"\"\\\\Qfirst-library.jar\\\\E\"", "\"^/META-INF/native-image/.*\"", "--exclude-config",
|
||||
"\"\\\\Qsecond-library.jar\\\\E\"", "\"^/META-INF/native-image/.*\"");
|
||||
"\\Qfirst-library.jar\\E", "^/META-INF/native-image/.*", "--exclude-config",
|
||||
"\\Qsecond-library.jar\\E", "^/META-INF/native-image/.*");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user