Skip to content

Commit 250c49c

Browse files
committed
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 required them eagerly.
1 parent 0f2ddd6 commit 250c49c

File tree

1 file changed

+11
-8
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl

1 file changed

+11
-8
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,19 @@ public void buildInfo(Action<BuildInfo> configurer) {
9696
TaskProvider<BuildInfo> bootBuildInfo = tasks.register("bootBuildInfo", BuildInfo.class,
9797
this::configureBuildInfoTask);
9898
this.project.getPlugins().withType(JavaPlugin.class, (plugin) -> {
99-
tasks.getByName(JavaPlugin.CLASSES_TASK_NAME).dependsOn(bootBuildInfo.get());
100-
this.project.afterEvaluate((evaluated) -> {
101-
BuildInfoProperties properties = bootBuildInfo.get().getProperties();
102-
if (properties.getArtifact() == null) {
103-
properties.setArtifact(determineArtifactBaseName());
104-
}
105-
});
99+
tasks.named(JavaPlugin.CLASSES_TASK_NAME)
100+
.configure((task) -> task.dependsOn(bootBuildInfo));
101+
this.project.afterEvaluate((evaluated) ->
102+
bootBuildInfo.configure(buildInfo -> {
103+
BuildInfoProperties properties = buildInfo.getProperties();
104+
if (properties.getArtifact() == null) {
105+
properties.setArtifact(determineArtifactBaseName());
106+
}
107+
})
108+
);
106109
});
107110
if (configurer != null) {
108-
configurer.execute(bootBuildInfo.get());
111+
bootBuildInfo.configure(configurer);
109112
}
110113
}
111114

0 commit comments

Comments
 (0)