From e95bcfac34aaa74f4c4f288775f3285666c304d5 Mon Sep 17 00:00:00 2001 From: Lukas Cardot Date: Mon, 21 Sep 2020 13:53:08 +0200 Subject: [PATCH] Configure the bootBuildInfo task lazily Prior to this commit, the bootBuildInfo was configured eagerly. Configuring it lazily prevent this task from being configured when not explicitly needed. Also, the 'classes' and 'bootJar' tasks are now lazily configured, as the bootBuildInfo task was causing them to be configured eagerly. See gh-23435 --- .../boot/gradle/dsl/SpringBootExtension.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java index 05bbf68ced..ebc3e27620 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java @@ -96,16 +96,16 @@ public class SpringBootExtension { TaskProvider bootBuildInfo = tasks.register("bootBuildInfo", BuildInfo.class, this::configureBuildInfoTask); this.project.getPlugins().withType(JavaPlugin.class, (plugin) -> { - tasks.getByName(JavaPlugin.CLASSES_TASK_NAME).dependsOn(bootBuildInfo.get()); - this.project.afterEvaluate((evaluated) -> { - BuildInfoProperties properties = bootBuildInfo.get().getProperties(); + tasks.named(JavaPlugin.CLASSES_TASK_NAME).configure((task) -> task.dependsOn(bootBuildInfo)); + this.project.afterEvaluate((evaluated) -> bootBuildInfo.configure((buildInfo) -> { + BuildInfoProperties properties = buildInfo.getProperties(); if (properties.getArtifact() == null) { properties.setArtifact(determineArtifactBaseName()); } - }); + })); }); if (configurer != null) { - configurer.execute(bootBuildInfo.get()); + bootBuildInfo.configure(configurer); } }