Skip to content

Commit 7edc9eb

Browse files
Eng-Fouadwilkinsona
authored andcommitted
Lazily query attributes when copying from base configuration
See gh-37343
1 parent 3eb8934 commit 7edc9eb

File tree

1 file changed

+4
-1
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.gradle.api.plugins.JavaPluginExtension;
3636
import org.gradle.api.plugins.PluginContainer;
3737
import org.gradle.api.provider.Provider;
38+
import org.gradle.api.provider.ProviderFactory;
3839
import org.gradle.api.tasks.SourceSet;
3940
import org.gradle.api.tasks.SourceSetContainer;
4041
import org.gradle.api.tasks.TaskProvider;
@@ -152,6 +153,7 @@ private void configureAotTask(Project project, SourceSet sourceSet, AbstractAot
152153

153154
@SuppressWarnings("unchecked")
154155
private Configuration createAotProcessingClasspath(Project project, String taskName, SourceSet inputSourceSet) {
156+
ProviderFactory providers = project.getProviders();
155157
Configuration base = project.getConfigurations()
156158
.getByName(inputSourceSet.getRuntimeClasspathConfigurationName());
157159
Configuration aotClasspath = project.getConfigurations().create(taskName + "Classpath", (classpath) -> {
@@ -162,7 +164,8 @@ private Configuration createAotProcessingClasspath(Project project, String taskN
162164
classpath.attributes((attributes) -> {
163165
AttributeContainer baseAttributes = base.getAttributes();
164166
for (Attribute<?> attribute : baseAttributes.keySet()) {
165-
attributes.attribute((Attribute<Object>) attribute, baseAttributes.getAttribute(attribute));
167+
Attribute<Object> attr = (Attribute<Object>) attribute;
168+
attributes.attributeProvider(attr, providers.provider(() -> baseAttributes.getAttribute(attr)));
166169
}
167170
});
168171
});

0 commit comments

Comments
 (0)