Fix reusable archive creation with Gradle 4.1 and later
Closes gh-11468
This commit is contained in:
@@ -29,6 +29,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.gradle.junit.GradleCompatibilitySuite;
|
||||
import org.springframework.boot.gradle.testkit.GradleBuild;
|
||||
import org.springframework.boot.loader.tools.FileUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -56,6 +57,21 @@ public abstract class AbstractBootArchiveIntegrationTests {
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reproducibleArchive() throws InvalidRunnerConfigurationException,
|
||||
UnexpectedBuildFailure, IOException, InterruptedException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs")
|
||||
.listFiles()[0];
|
||||
String firstHash = FileUtils.sha1Hash(jar);
|
||||
Thread.sleep(1500);
|
||||
assertThat(this.gradleBuild.build("clean", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String secondHash = FileUtils.sha1Hash(jar);
|
||||
assertThat(firstHash).isEqualTo(secondHash);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upToDateWhenBuiltTwice() throws InvalidRunnerConfigurationException,
|
||||
UnexpectedBuildFailure, IOException {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath files(pluginClasspath.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
bootJar {
|
||||
mainClassName = 'com.example.Application'
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath files(pluginClasspath.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'war'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
bootWar {
|
||||
mainClassName = 'com.example.Application'
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
Reference in New Issue
Block a user