Fail fast when attempting to repackage a reproducible war

Maven's war plugin does not support reproducible builds, resulting in
the entries in the war file not being written in a consistent order
from build to build.

Closes gh-20176
This commit is contained in:
Andy Wilkinson
2020-03-16 20:29:37 +00:00
parent ca202ad59f
commit c4a55a5fb4
3 changed files with 13 additions and 31 deletions

View File

@@ -21,6 +21,7 @@ import java.io.IOException;
import java.nio.file.attribute.FileTime;
import java.util.jar.JarFile;
import org.springframework.boot.loader.tools.Layouts.War;
import org.springframework.util.Assert;
/**
@@ -100,6 +101,9 @@ public class Repackager extends Packager {
public void repackage(File destination, Libraries libraries, LaunchScript launchScript, FileTime lastModifiedTime)
throws IOException {
Assert.isTrue(destination != null && !destination.isDirectory(), "Invalid destination");
if (lastModifiedTime != null && getLayout() instanceof War) {
throw new IllegalStateException("Reproducible repackaging is not supported with war packaging");
}
destination = destination.getAbsoluteFile();
File source = getSource();
if (isAlreadyPackaged() && source.equals(destination)) {