mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish "Lazily query attributes when copying from base configuration"
See gh-37343
This commit is contained in:
parent
7edc9ebc28
commit
a795065555
@ -151,9 +151,8 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
task.getArtifactId().set(project.provider(() -> project.getName()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private Configuration createAotProcessingClasspath(Project project, String taskName, SourceSet inputSourceSet) {
|
||||
ProviderFactory providers = project.getProviders();
|
||||
Configuration base = project.getConfigurations()
|
||||
.getByName(inputSourceSet.getRuntimeClasspathConfigurationName());
|
||||
Configuration aotClasspath = project.getConfigurations().create(taskName + "Classpath", (classpath) -> {
|
||||
@ -162,10 +161,11 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
classpath.setDescription("Classpath of the " + taskName + " task.");
|
||||
removeDevelopmentOnly(base.getExtendsFrom()).forEach(classpath::extendsFrom);
|
||||
classpath.attributes((attributes) -> {
|
||||
ProviderFactory providers = project.getProviders();
|
||||
AttributeContainer baseAttributes = base.getAttributes();
|
||||
for (Attribute<?> attribute : baseAttributes.keySet()) {
|
||||
Attribute<Object> attr = (Attribute<Object>) attribute;
|
||||
attributes.attributeProvider(attr, providers.provider(() -> baseAttributes.getAttribute(attr)));
|
||||
for (Attribute attribute : baseAttributes.keySet()) {
|
||||
attributes.attributeProvider(attribute,
|
||||
providers.provider(() -> baseAttributes.getAttribute(attribute)));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -23,11 +23,14 @@ import java.util.List;
|
||||
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.condition.EnabledOnJre;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
|
||||
import org.springframework.boot.gradle.junit.GradleCompatibility;
|
||||
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SpringBootAotPlugin}.
|
||||
@ -121,6 +124,13 @@ class SpringBootAotPluginIntegrationTests {
|
||||
.isEqualTo(TaskOutcome.NO_SOURCE);
|
||||
}
|
||||
|
||||
// gh-37343
|
||||
@TestTemplate
|
||||
@EnabledOnJre(JRE.JAVA_17)
|
||||
void applyingAotPluginDoesNotPreventConfigurationOfJavaToolchainLanguageVersion() {
|
||||
assertThatNoException().isThrownBy(() -> this.gradleBuild.build("help").getOutput());
|
||||
}
|
||||
|
||||
private void writeMainClass(String packageName, String className) throws IOException {
|
||||
File java = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/main/java/" + packageName.replace(".", "/") + "/" + className + ".java");
|
||||
|
@ -0,0 +1,11 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot'
|
||||
id 'org.springframework.boot.aot'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user