Skip to content

Update to Kotlin 2.2 #17380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id "java-gradle-plugin"
id "groovy-gradle-plugin"
id "java"
id "groovy"
}
Expand Down Expand Up @@ -76,6 +77,7 @@ dependencies {
implementation libs.com.github.spullara.mustache.java.compiler
implementation libs.io.spring.javaformat.spring.javaformat.gradle.plugin
implementation libs.io.spring.nohttp.nohttp.gradle
implementation libs.org.jetbrains.kotlin.kotlin.gradle.plugin
implementation (libs.net.sourceforge.htmlunit) {
exclude group: 'org.eclipse.jetty.websocket', module: 'websocket-client'
}
Expand Down
17 changes: 17 additions & 0 deletions buildSrc/src/main/groovy/security-kotlin.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'kotlin'
}

project.plugins.withId("org.jetbrains.kotlin.jvm", (kotlinProject) -> {
project.tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
languageVersion = '2.2'
apiVersion = '2.2'
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings"]
jvmTarget = '17'

}
}
})
11 changes: 1 addition & 10 deletions config/spring-security-config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import trang.RncToXsd

apply plugin: 'io.spring.convention.spring-module'
apply plugin: 'trang'
apply plugin: 'kotlin'
apply plugin: 'security-kotlin'

configurations {
opensaml5 {
Expand Down Expand Up @@ -153,15 +153,6 @@ tasks.named('sourcesJar', Jar).configure {
}
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
languageVersion = "1.7"
apiVersion = "1.7"
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings"]
jvmTarget = "17"
}
}

configure(project.tasks.withType(Test)) {
doFirst {
systemProperties['springSecurityVersion'] = version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class ServerX509DslTests {
@Nullable httpHandlerBuilder: WebHttpHandlerBuilder?,
@Nullable connector: ClientHttpConnector?) {
val filter = SetSslInfoWebFilter(certificate)
httpHandlerBuilder!!.filters { filters: MutableList<WebFilter?> -> filters.add(0, filter) }
httpHandlerBuilder!!.filters { filters: MutableList<WebFilter> -> filters.add(0, filter) }
}
}

Expand Down
13 changes: 1 addition & 12 deletions core/spring-security-core.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

import java.util.concurrent.Callable

apply plugin: 'io.spring.convention.spring-module'
apply plugin: 'kotlin'
apply plugin: 'security-kotlin'

dependencies {
management platform(project(":spring-security-dependencies"))
Expand Down Expand Up @@ -66,12 +64,3 @@ Callable<String> springVersion() {
return (Callable<String>) { project.configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts
.find { it.name == 'spring-core' }.moduleVersion.id.version }
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
languageVersion = "1.7"
apiVersion = "1.7"
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings"]
jvmTarget = "17"
}
}
13 changes: 1 addition & 12 deletions docs/spring-security-docs.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'org.antora' version '1.0.0'
id 'io.spring.antora.generate-antora-yml' version '0.0.1'
id 'io.spring.convention.repository'
id 'kotlin'
id 'security-kotlin'
}

apply plugin: 'io.spring.convention.docs'
Expand Down Expand Up @@ -100,12 +98,3 @@ def resolvedVersions(Configuration configuration) {
test {
useJUnitPlatform()
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
languageVersion = "1.7"
apiVersion = "1.7"
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings"]
jvmTarget = "17"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class ServerWebClientHttpInterfaceIntegrationConfiguration {

@Bean
fun groupConfigurer(server: MockWebServer): WebClientHttpServiceGroupConfigurer {
return WebClientHttpServiceGroupConfigurer { groups: HttpServiceGroupConfigurer.Groups<WebClient.Builder?>? ->
return WebClientHttpServiceGroupConfigurer { groups: HttpServiceGroupConfigurer.Groups<WebClient.Builder> ->
val baseUrl = server.url("").toString()
groups!!
.forEachClient(ClientCallback { group: HttpServiceGroup?, builder: WebClient.Builder? ->
builder!!
.forEachClient(ClientCallback { group: HttpServiceGroup, builder: WebClient.Builder ->
builder
.baseUrl(baseUrl)
.defaultHeader("Accept", "application/vnd.github.v3+json")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.springframework.security.test.web.reactive.server.WebTestClientBuilde
import org.springframework.security.web.authentication.preauth.x509.X509TestUtils
import org.springframework.test.web.reactive.server.WebTestClient
import org.springframework.test.web.reactive.server.WebTestClientConfigurer
import org.springframework.util.Assert
import org.springframework.web.server.ServerWebExchange
import org.springframework.web.server.WebFilter
import org.springframework.web.server.WebFilterChain
Expand Down Expand Up @@ -108,18 +109,19 @@ class X509ConfigurationTests {

companion object {
private fun x509(certificate: X509Certificate): WebTestClientConfigurer {
return WebTestClientConfigurer { builder: WebTestClient.Builder, httpHandlerBuilder: WebHttpHandlerBuilder, connector: ClientHttpConnector? ->
return WebTestClientConfigurer { builder: WebTestClient.Builder, httpHandlerBuilder: WebHttpHandlerBuilder?, connector: ClientHttpConnector? ->

val sslInfo: SslInfo = object : SslInfo {
override fun getSessionId(): String {
return "sessionId"
}

override fun getPeerCertificates(): Array<X509Certificate?> {
override fun getPeerCertificates(): Array<X509Certificate> {
return arrayOf(certificate)
}
}
httpHandlerBuilder.filters(Consumer { filters: MutableList<WebFilter> ->
Assert.notNull(httpHandlerBuilder, "httpHandlerBuilder should not be null")
httpHandlerBuilder!!.filters(Consumer { filters: MutableList<WebFilter> ->
filters.add(
0,
SslInfoOverrideWebFilter(sslInfo)
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org-apache-maven-resolver = "1.9.23"
org-aspectj = "1.9.24"
org-bouncycastle = "1.80"
org-eclipse-jetty = "11.0.25"
org-jetbrains-kotlin = "1.9.25"
org-jetbrains-kotlin = "2.2.0"
org-jetbrains-kotlinx = "1.10.2"
org-mockito = "5.17.0"
org-opensaml = "4.3.2"
Expand Down Expand Up @@ -67,7 +67,7 @@ org-hamcrest = "org.hamcrest:hamcrest:2.2"
org-hibernate-orm-hibernate-core = "org.hibernate.orm:hibernate-core:7.0.1.Final"
org-hsqldb = "org.hsqldb:hsqldb:2.7.4"
org-jetbrains-kotlin-kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "org-jetbrains-kotlin" }
org-jetbrains-kotlin-kotlin-gradle-plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25"
org-jetbrains-kotlin-kotlin-gradle-plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.0"
org-jetbrains-kotlinx-kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "org-jetbrains-kotlinx" }
org-junit-junit-bom = "org.junit:junit-bom:5.12.2"
org-mockito-mockito-bom = { module = "org.mockito:mockito-bom", version.ref = "org-mockito" }
Expand Down