Preserve timestamps on loader directories
Prior to this commit, when the Maven plugin copied spring-boot-loader.jar to a repackaged archive the timestamps of class files were preserved but the timestamps of directories were not preserved. This resulted in the directories having a current timestamp. This commit copies the directory timestamps from spring-boot-loader.jar to the repackaged archive and adds tests to verify the proper behavior. See gh-20927
This commit is contained in:
@@ -209,13 +209,21 @@ public abstract class AbstractJarWriter implements LoaderClassesWriter {
|
||||
try (JarInputStream inputStream = new JarInputStream(new BufferedInputStream(loaderJar.openStream()))) {
|
||||
JarEntry entry;
|
||||
while ((entry = inputStream.getNextJarEntry()) != null) {
|
||||
if (entry.getName().endsWith(".class")) {
|
||||
if (isDirectoryEntry(entry) || isClassEntry(entry)) {
|
||||
writeEntry(new JarArchiveEntry(entry), new InputStreamEntryWriter(inputStream));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDirectoryEntry(JarEntry entry) {
|
||||
return entry.isDirectory() && !entry.getName().equals("META-INF/");
|
||||
}
|
||||
|
||||
private boolean isClassEntry(JarEntry entry) {
|
||||
return entry.getName().endsWith(".class");
|
||||
}
|
||||
|
||||
private void writeEntry(JarArchiveEntry entry, EntryWriter entryWriter) throws IOException {
|
||||
writeEntry(entry, entryWriter, UnpackHandler.NEVER);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user