Commit 57db621b authored by Phillip Webb's avatar Phillip Webb

Polish

parent 77bbe089
...@@ -177,8 +177,8 @@ public class BootJar extends Jar implements BootArchive { ...@@ -177,8 +177,8 @@ public class BootJar extends Jar implements BootArchive {
this.bootInf.eachFile((details) -> { this.bootInf.eachFile((details) -> {
Layer layer = layerForFileDetails(details); Layer layer = layerForFileDetails(details);
if (layer != null) { if (layer != null) {
details.setPath( String relativePath = details.getPath().substring("BOOT-INF/".length());
BOOT_INF_LAYERS + "/" + layer + "/" + details.getPath().substring("BOOT-INF/".length())); details.setPath(BOOT_INF_LAYERS + "/" + layer + "/" + relativePath);
} }
}).setIncludeEmptyDirs(false); }).setIncludeEmptyDirs(false);
this.bootInf.into("", (spec) -> spec.from(createLayersIndex())); this.bootInf.into("", (spec) -> spec.from(createLayersIndex()));
......
...@@ -159,6 +159,7 @@ public abstract class Packager { ...@@ -159,6 +159,7 @@ public abstract class Packager {
writeLoaderClasses(writer); writeLoaderClasses(writer);
writer.writeEntries(sourceJar, getEntityTransformer(), writeableLibraries); writer.writeEntries(sourceJar, getEntityTransformer(), writeableLibraries);
writeableLibraries.write(writer); writeableLibraries.write(writer);
writeLayerIndex(writer); writeLayerIndex(writer);
} }
...@@ -425,14 +426,14 @@ public abstract class Packager { ...@@ -425,14 +426,14 @@ public abstract class Packager {
*/ */
private final class WritableLibraries implements UnpackHandler { private final class WritableLibraries implements UnpackHandler {
private final Map<String, Library> libraryEntryNames = new LinkedHashMap<>(); private final Map<String, Library> libraries = new LinkedHashMap<>();
WritableLibraries(Libraries libraries) throws IOException { WritableLibraries(Libraries libraries) throws IOException {
libraries.doWithLibraries((library) -> { libraries.doWithLibraries((library) -> {
if (isZip(library.getFile())) { if (isZip(library.getFile())) {
String location = getLocation(library); String location = getLocation(library);
if (location != null) { if (location != null) {
Library existing = this.libraryEntryNames.putIfAbsent(location + library.getName(), library); Library existing = this.libraries.putIfAbsent(location + library.getName(), library);
Assert.state(existing == null, "Duplicate library " + library.getName()); Assert.state(existing == null, "Duplicate library " + library.getName());
} }
} }
...@@ -452,25 +453,25 @@ public abstract class Packager { ...@@ -452,25 +453,25 @@ public abstract class Packager {
@Override @Override
public boolean requiresUnpack(String name) { public boolean requiresUnpack(String name) {
Library library = this.libraryEntryNames.get(name); Library library = this.libraries.get(name);
return library != null && library.isUnpackRequired(); return library != null && library.isUnpackRequired();
} }
@Override @Override
public String sha1Hash(String name) throws IOException { public String sha1Hash(String name) throws IOException {
Library library = this.libraryEntryNames.get(name); Library library = this.libraries.get(name);
Assert.notNull(library, "No library found for entry name '" + name + "'"); Assert.notNull(library, "No library found for entry name '" + name + "'");
return FileUtils.sha1Hash(library.getFile()); return FileUtils.sha1Hash(library.getFile());
} }
private void write(AbstractJarWriter writer) throws IOException { private void write(AbstractJarWriter writer) throws IOException {
for (Entry<String, Library> entry : this.libraryEntryNames.entrySet()) { for (Entry<String, Library> entry : this.libraries.entrySet()) {
writer.writeNestedLibrary(entry.getKey().substring(0, entry.getKey().lastIndexOf('/') + 1), writer.writeNestedLibrary(entry.getKey().substring(0, entry.getKey().lastIndexOf('/') + 1),
entry.getValue()); entry.getValue());
} }
if (getLayout() instanceof RepackagingLayout) { if (getLayout() instanceof RepackagingLayout) {
String location = ((RepackagingLayout) getLayout()).getClasspathIndexFileLocation(); String location = ((RepackagingLayout) getLayout()).getClasspathIndexFileLocation();
writer.writeIndexFile(location, new ArrayList<>(this.libraryEntryNames.keySet())); writer.writeIndexFile(location, new ArrayList<>(this.libraries.keySet()));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment