Skip to content

Commit

Permalink
Merge branch '3.0.x' into 3.1.x
Browse files Browse the repository at this point in the history
Closes gh-37380
  • Loading branch information
wilkinsona committed Sep 14, 2023
2 parents fdd9bc7 + 54b6ab0 commit dfb9532
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.plugins.PluginContainer;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskProvider;
Expand Down Expand Up @@ -150,7 +151,7 @@ private void configureAotTask(Project project, SourceSet sourceSet, AbstractAot
task.getArtifactId().set(project.provider(() -> project.getName()));
}

@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
private Configuration createAotProcessingClasspath(Project project, String taskName, SourceSet inputSourceSet) {
Configuration base = project.getConfigurations()
.getByName(inputSourceSet.getRuntimeClasspathConfigurationName());
Expand All @@ -160,9 +161,11 @@ private Configuration createAotProcessingClasspath(Project project, String taskN
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()) {
attributes.attribute((Attribute<Object>) attribute, baseAttributes.getAttribute(attribute));
for (Attribute attribute : baseAttributes.keySet()) {
attributes.attributeProvider(attribute,
providers.provider(() -> baseAttributes.getAttribute(attribute)));
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@

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}.
Expand Down Expand Up @@ -121,6 +124,13 @@ void processTestAotIsSkippedWhenProjectHasNoTestSource() {
.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");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
id 'org.springframework.boot'
id 'org.springframework.boot.aot'
id 'java'
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

0 comments on commit dfb9532

Please sign in to comment.