commit
f8b75073e8
|
@ -45,10 +45,10 @@ class IndexedLayers implements Layers {
|
||||||
|
|
||||||
private final Map<String, List<String>> layers = new LinkedHashMap<>();
|
private final Map<String, List<String>> layers = new LinkedHashMap<>();
|
||||||
|
|
||||||
private final String classesLocation;
|
private final String indexFileLocation;
|
||||||
|
|
||||||
IndexedLayers(String indexFile, String classesLocation) {
|
IndexedLayers(String indexFile, String indexFileLocation) {
|
||||||
this.classesLocation = classesLocation;
|
this.indexFileLocation = indexFileLocation;
|
||||||
String[] lines = Arrays.stream(indexFile.split("\n"))
|
String[] lines = Arrays.stream(indexFile.split("\n"))
|
||||||
.map((line) -> line.replace("\r", ""))
|
.map((line) -> line.replace("\r", ""))
|
||||||
.filter(StringUtils::hasText)
|
.filter(StringUtils::hasText)
|
||||||
|
@ -72,7 +72,7 @@ class IndexedLayers implements Layers {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getApplicationLayerName() {
|
public String getApplicationLayerName() {
|
||||||
return getLayer(this.classesLocation);
|
return getLayer(this.indexFileLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,18 +99,21 @@ class IndexedLayers implements Layers {
|
||||||
* jar.
|
* jar.
|
||||||
*/
|
*/
|
||||||
static IndexedLayers get(Context context) {
|
static IndexedLayers get(Context context) {
|
||||||
try {
|
try (JarFile jarFile = new JarFile(context.getArchiveFile())) {
|
||||||
try (JarFile jarFile = new JarFile(context.getArchiveFile())) {
|
Manifest manifest = jarFile.getManifest();
|
||||||
Manifest manifest = jarFile.getManifest();
|
if (manifest == null) {
|
||||||
String location = manifest.getMainAttributes().getValue("Spring-Boot-Layers-Index");
|
return null;
|
||||||
ZipEntry entry = (location != null) ? jarFile.getEntry(location) : null;
|
|
||||||
if (entry != null) {
|
|
||||||
String indexFile = StreamUtils.copyToString(jarFile.getInputStream(entry), StandardCharsets.UTF_8);
|
|
||||||
String classesLocation = manifest.getMainAttributes().getValue("Spring-Boot-Classes");
|
|
||||||
return new IndexedLayers(indexFile, classesLocation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
String indexFileLocation = manifest.getMainAttributes().getValue("Spring-Boot-Layers-Index");
|
||||||
|
if (indexFileLocation == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ZipEntry entry = jarFile.getEntry(indexFileLocation);
|
||||||
|
if (entry == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String indexFile = StreamUtils.copyToString(jarFile.getInputStream(entry), StandardCharsets.UTF_8);
|
||||||
|
return new IndexedLayers(indexFile, indexFileLocation);
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException | NoSuchFileException ex) {
|
catch (FileNotFoundException | NoSuchFileException ex) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue