Remove META-INF/INDEX.LIST when repackaging a jar file
META-INF/INDEX.LIST files are pointless in an executable jar and moving application classes from the root of the jar to BOOT-INF/classes breaks the index, resulting in an InvalidJarIndexException being thrown. This commit updates the Repackager to automatically remove a META-INF/INDEX.LIST file from a jar file that is being repackaged. Closes gh-6601
This commit is contained in:
@@ -141,7 +141,10 @@ public class JarWriter {
|
||||
jarFile.getInputStream(entry));
|
||||
}
|
||||
EntryWriter entryWriter = new InputStreamEntryWriter(inputStream, true);
|
||||
writeEntry(entryTransformer.transform(entry), entryWriter);
|
||||
JarEntry transformedEntry = entryTransformer.transform(entry);
|
||||
if (transformedEntry != null) {
|
||||
writeEntry(transformedEntry, entryWriter);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
inputStream.close();
|
||||
|
||||
@@ -337,6 +337,9 @@ public class Repackager {
|
||||
|
||||
@Override
|
||||
public JarEntry transform(JarEntry entry) {
|
||||
if (entry.getName().equals("META-INF/INDEX.LIST")) {
|
||||
return null;
|
||||
}
|
||||
if (entry.getName().startsWith("META-INF/")
|
||||
|| entry.getName().startsWith("BOOT-INF/")) {
|
||||
return entry;
|
||||
|
||||
Reference in New Issue
Block a user