Configure Gradle toolchain auto-provisioning
This commit configures the Foojay resolver plugin in the Gradle build in order to auto-provision a required JDK distribution if it's not present already on the host. Currently the Spring Framework build requires both a JDK 17 and a JDK 21 distribution to build artifacts. Closes gh-30474
This commit is contained in:
parent
0aec9f12ce
commit
8708a21143
|
@ -27,6 +27,8 @@ import org.gradle.api.plugins.JavaPlugin;
|
|||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.jvm.toolchain.JavaLanguageVersion;
|
||||
import org.gradle.jvm.toolchain.JavaToolchainSpec;
|
||||
import org.gradle.jvm.toolchain.JvmVendorSpec;
|
||||
|
||||
/**
|
||||
* {@link Plugin} that applies conventions for compiling Java sources in Spring Framework.
|
||||
|
@ -70,8 +72,10 @@ public class JavaConventions {
|
|||
* @param project the current project
|
||||
*/
|
||||
private void applyJavaCompileConventions(Project project) {
|
||||
project.getExtensions().getByType(JavaPluginExtension.class)
|
||||
.getToolchain().getLanguageVersion().set(JavaLanguageVersion.of(17));
|
||||
project.getExtensions().getByType(JavaPluginExtension.class).toolchain(toolchain -> {
|
||||
toolchain.getVendor().set(JvmVendorSpec.BELLSOFT);
|
||||
toolchain.getLanguageVersion().set(JavaLanguageVersion.of(17));
|
||||
});
|
||||
project.getTasks().withType(JavaCompile.class)
|
||||
.matching(compileTask -> compileTask.getName().equals(JavaPlugin.COMPILE_JAVA_TASK_NAME))
|
||||
.forEach(compileTask -> {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
plugins {
|
||||
id "com.gradle.enterprise" version "3.14"
|
||||
id "io.spring.ge.conventions" version "0.0.13"
|
||||
id "org.gradle.toolchains.foojay-resolver-convention" version "0.7.0"
|
||||
}
|
||||
|
||||
include "spring-aop"
|
||||
|
|
Loading…
Reference in New Issue