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:
parent
a8e701cee2
commit
c16c6bc3b5
|
|
@ -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/.*");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -241,15 +241,14 @@ public abstract class Packager {
|
|||
}
|
||||
}
|
||||
}
|
||||
// https://docs.oracle.com/en/java/javase/18/docs/specs/man/java.html#java-command-line-argument-files
|
||||
if (!excludes.isEmpty()) {
|
||||
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/.*");
|
||||
}
|
||||
String contents = args.stream().collect(Collectors.joining("\n")) + "\n";
|
||||
writer.writeEntry("META-INF/native-image/argfile",
|
||||
|
|
|
|||
|
|
@ -643,11 +643,11 @@ abstract class AbstractPackagerTests<P extends Packager> {
|
|||
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add("--exclude-config");
|
||||
expected.add("\"\\\\Q" + libraryOne.getName() + "\\\\E\"");
|
||||
expected.add("\"^/META-INF/native-image/.*\"");
|
||||
expected.add("\\Q" + libraryOne.getName() + "\\E");
|
||||
expected.add("^/META-INF/native-image/.*");
|
||||
expected.add("--exclude-config");
|
||||
expected.add("\"\\\\Q" + libraryTwo.getName() + "\\\\E\"");
|
||||
expected.add("\"^/META-INF/native-image/.*\"");
|
||||
expected.add("\\Q" + libraryTwo.getName() + "\\E");
|
||||
expected.add("^/META-INF/native-image/.*");
|
||||
assertThat(getPackagedEntryContent("META-INF/native-image/argfile"))
|
||||
.isEqualTo(expected.stream().collect(Collectors.joining("\n")) + "\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue