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 {
|
||||
|
||||
Reference in New Issue
Block a user