Externalize java-toolchain configuration
We should not use subprojects to perform configuration becaause it does not allow for lazy loading and it can cause ordering problems. In this case, the toolchain was not being used but instead it was using the JAVA_HOME. By splitting the configuration into a plugin and applying it to each project it fixes the toolchain configuration
This commit is contained in:
@@ -48,37 +48,6 @@ springRelease {
|
|||||||
replaceSnapshotVersionInReferenceDocUrl = true
|
replaceSnapshotVersionInReferenceDocUrl = true
|
||||||
}
|
}
|
||||||
|
|
||||||
def toolchainVersion() {
|
|
||||||
if (project.hasProperty('testToolchain')) {
|
|
||||||
return project.property('testToolchain').toString().toInteger()
|
|
||||||
}
|
|
||||||
return 25
|
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion = JavaLanguageVersion.of(toolchainVersion())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
kotlin {
|
|
||||||
jvmToolchain {
|
|
||||||
languageVersion = JavaLanguageVersion.of(toolchainVersion())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
options.compilerArgs.add("-parameters")
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
tasks.withType(KotlinCompile).configureEach {
|
|
||||||
compilerOptions {
|
|
||||||
javaParameters = true
|
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
if (!['spring-security-bom', 'spring-security-docs'].contains(project.name)) {
|
if (!['spring-security-bom', 'spring-security-docs'].contains(project.name)) {
|
||||||
apply plugin: 'io.spring.javaformat'
|
apply plugin: 'io.spring.javaformat'
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class SpringModulePlugin extends AbstractSpringJavaPlugin {
|
|||||||
pluginManager.apply(SpringMavenPlugin.class);
|
pluginManager.apply(SpringMavenPlugin.class);
|
||||||
pluginManager.apply(CheckClasspathForProhibitedDependenciesPlugin.class);
|
pluginManager.apply(CheckClasspathForProhibitedDependenciesPlugin.class);
|
||||||
pluginManager.apply("io.spring.convention.jacoco");
|
pluginManager.apply("io.spring.convention.jacoco");
|
||||||
|
pluginManager.apply("java-toolchain");
|
||||||
|
|
||||||
def deployArtifacts = project.task("deployArtifacts")
|
def deployArtifacts = project.task("deployArtifacts")
|
||||||
deployArtifacts.group = 'Deploy tasks'
|
deployArtifacts.group = 'Deploy tasks'
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
def toolchainVersion() {
|
||||||
|
if (project.hasProperty('testToolchain')) {
|
||||||
|
return project.property('testToolchain').toString().toInteger()
|
||||||
|
}
|
||||||
|
return 25
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(toolchainVersion())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
options.compilerArgs.add("-parameters")
|
||||||
|
options.release = 17
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(toolchainVersion())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(KotlinCompile).configureEach {
|
||||||
|
compilerOptions {
|
||||||
|
javaParameters = true
|
||||||
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ plugins {
|
|||||||
id 'io.spring.antora.generate-antora-yml' version '0.0.1'
|
id 'io.spring.antora.generate-antora-yml' version '0.0.1'
|
||||||
id 'io.spring.convention.repository'
|
id 'io.spring.convention.repository'
|
||||||
id 'security-kotlin'
|
id 'security-kotlin'
|
||||||
|
id 'java-toolchain'
|
||||||
|
id 'test-compile-target-jdk25'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'io.spring.convention.docs'
|
apply plugin: 'io.spring.convention.docs'
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
apply plugin: 'io.spring.convention.spring-test'
|
apply plugin: 'io.spring.convention.spring-test'
|
||||||
|
apply plugin: 'java-toolchain'
|
||||||
|
apply plugin: 'test-compile-target-jdk25'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation platform(project(":spring-security-dependencies"))
|
implementation platform(project(":spring-security-dependencies"))
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
plugins {
|
plugins {
|
||||||
|
id 'io.spring.convention.spring-module'
|
||||||
id 'security-nullability'
|
id 'security-nullability'
|
||||||
id 'javadoc-warnings-error'
|
id 'javadoc-warnings-error'
|
||||||
id 'test-compile-target-jdk25'
|
id 'test-compile-target-jdk25'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'io.spring.convention.spring-module'
|
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
javascript {
|
javascript {
|
||||||
canBeConsumed = false
|
canBeConsumed = false
|
||||||
|
|||||||
Reference in New Issue
Block a user