commit
899e8e189b
|
@ -101,6 +101,7 @@ 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");
|
||||
getLayout(); // get layout early
|
||||
if (lastModifiedTime != null && getLayout() instanceof War) {
|
||||
throw new IllegalStateException("Reproducible repackaging is not supported with war packaging");
|
||||
}
|
||||
|
|
|
@ -139,6 +139,15 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
|
|||
assertThat(hasLauncherClasses(this.destination)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void layoutFactoryGetsOriginalFile() throws Exception {
|
||||
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
|
||||
Repackager repackager = createRepackager(this.testJarFile.getFile(), false);
|
||||
repackager.setLayoutFactory(new TestLayoutFactory());
|
||||
repackager.repackage(this.destination, NO_LIBRARIES);
|
||||
assertThat(hasLauncherClasses(this.destination)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void addLauncherScript() throws Exception {
|
||||
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
|
||||
|
@ -266,4 +275,14 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
|
|||
|
||||
}
|
||||
|
||||
static class TestLayoutFactory implements LayoutFactory {
|
||||
|
||||
@Override
|
||||
public Layout getLayout(File source) {
|
||||
assertThat(source.length()).isGreaterThan(0);
|
||||
return new DefaultLayoutFactory().getLayout(source);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue