Update BootBuildImage to support Gradle's configuration cache

See gh-22922
pull/23886/head
Andy Wilkinson 4 years ago
parent b1c4af4081
commit 806464edd1

@ -59,6 +59,10 @@ public class BootBuildImage extends DefaultTask {
private static final String BUILDPACK_JVM_VERSION_KEY = "BP_JVM_VERSION"; private static final String BUILDPACK_JVM_VERSION_KEY = "BP_JVM_VERSION";
private final String projectName;
private final Property<String> projectVersion;
private RegularFileProperty jar; private RegularFileProperty jar;
private Property<JavaVersion> targetJavaVersion; private Property<JavaVersion> targetJavaVersion;
@ -84,6 +88,9 @@ public class BootBuildImage extends DefaultTask {
public BootBuildImage() { public BootBuildImage() {
this.jar = getProject().getObjects().fileProperty(); this.jar = getProject().getObjects().fileProperty();
this.targetJavaVersion = getProject().getObjects().property(JavaVersion.class); this.targetJavaVersion = getProject().getObjects().property(JavaVersion.class);
this.projectName = getProject().getName();
this.projectVersion = getProject().getObjects().property(String.class);
this.projectVersion.set(getProject().provider(() -> getProject().getVersion().toString()));
} }
/** /**
@ -318,12 +325,11 @@ public class BootBuildImage extends DefaultTask {
if (StringUtils.hasText(this.imageName)) { if (StringUtils.hasText(this.imageName)) {
return ImageReference.of(this.imageName); return ImageReference.of(this.imageName);
} }
ImageName imageName = ImageName.of(getProject().getName()); ImageName imageName = ImageName.of(this.projectName);
String version = getProject().getVersion().toString(); if ("unspecified".equals(this.projectVersion.get())) {
if ("unspecified".equals(version)) {
return ImageReference.of(imageName); return ImageReference.of(imageName);
} }
return ImageReference.of(imageName, version); return ImageReference.of(imageName, this.projectVersion.get());
} }
private BuildRequest customize(BuildRequest request) { private BuildRequest customize(BuildRequest request) {

@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Scott Frederick * @author Scott Frederick
*/ */
@GradleCompatibility @GradleCompatibility(configurationCache = true)
@DisabledIfDockerUnavailable @DisabledIfDockerUnavailable
class BootBuildImageIntegrationTests { class BootBuildImageIntegrationTests {

Loading…
Cancel
Save