Use YAML compatible classpath.idx format
Update the `classpath.idx` format to align with `layers.idx` and allow third-parties can parse it as YAML Closes gh-20861
This commit is contained in:
@@ -31,6 +31,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A class path index file that provides ordering information for JARs.
|
||||
*
|
||||
@@ -45,7 +47,12 @@ final class ClassPathIndexFile {
|
||||
|
||||
private ClassPathIndexFile(File root, List<String> lines) {
|
||||
this.root = root;
|
||||
this.lines = lines;
|
||||
this.lines = lines.stream().map(this::extractName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String extractName(String line) {
|
||||
Assert.state(line.startsWith("- \"") && line.endsWith("\""), "Malformed classpath index line [" + line + "]");
|
||||
return line.substring(3, line.length() - 1);
|
||||
}
|
||||
|
||||
int size() {
|
||||
|
||||
@@ -68,9 +68,9 @@ public abstract class AbstractExecutableArchiveLauncherTests {
|
||||
JarEntry indexEntry = new JarEntry(entryPrefix + "/classpath.idx");
|
||||
jarOutputStream.putNextEntry(indexEntry);
|
||||
Writer writer = new OutputStreamWriter(jarOutputStream, StandardCharsets.UTF_8);
|
||||
writer.write("BOOT-INF/lib/foo.jar\n");
|
||||
writer.write("BOOT-INF/lib/bar.jar\n");
|
||||
writer.write("BOOT-INF/lib/baz.jar\n");
|
||||
writer.write("- \"BOOT-INF/lib/foo.jar\"\n");
|
||||
writer.write("- \"BOOT-INF/lib/bar.jar\"\n");
|
||||
writer.write("- \"BOOT-INF/lib/baz.jar\"\n");
|
||||
writer.flush();
|
||||
}
|
||||
addNestedJars(entryPrefix, "/lib/foo.jar", jarOutputStream);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
a.jar
|
||||
b.jar
|
||||
c.jar
|
||||
d.jar
|
||||
e.jar
|
||||
- "a.jar"
|
||||
- "b.jar"
|
||||
- "c.jar"
|
||||
- "d.jar"
|
||||
- "e.jar"
|
||||
|
||||
Reference in New Issue
Block a user