diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java index 0259b14507..7aa6c2c7a5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java @@ -90,7 +90,8 @@ public class BootBuildImage extends DefaultTask { 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())); + Project project = getProject(); + this.projectVersion.set(getProject().provider(() -> project.getVersion().toString())); } /**