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:
Phillip Webb
2020-04-06 16:09:57 -07:00
parent 65672a1150
commit df58b9baa2
7 changed files with 36 additions and 22 deletions

View File

@@ -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() {