Skip to content

Commit 1d9bbc4

Browse files
committed
Upgrade to Kotlin 2.1.10
- Upgrade kotlinVersion to 2.1.10 - Remove org.jetbrains.kotlin:kotlin-compiler-embeddable from dependencies - Replace deprecated kotlinOptions with compilerOptions - Update KotlinConventions of ConventionsPlugin to set Kotlin apiVersion and languageVersion to 2.1 - Move spring-boot-doc Kotlin examples to kotlin subpackage to prevent Redeclaration compile error - Upgrade PluginClasspathGradleBuild to inject missed Kotlin compiler related jars See spring-projectsgh-38539 Signed-off-by: Dmitry Sulman <[email protected]>
1 parent 7b9da78 commit 1d9bbc4

File tree

366 files changed

+438
-400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+438
-400
lines changed

buildSrc/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ dependencies {
4242
implementation("org.apache.maven:maven-embedder:${mavenVersion}")
4343
implementation("org.antora:gradle-antora-plugin:1.0.0")
4444
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
45-
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}")
4645
implementation("org.springframework:spring-context")
4746
implementation("org.springframework:spring-core")
4847
implementation("org.springframework:spring-web")

buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,9 @@
3535
* When the {@link AntoraPlugin} is applied, the conventions in {@link AntoraConventions}
3636
* are applied.
3737
*
38+
* When the {@code org.jetbrains.kotlin.jvm} plugin is applied, the conventions in
39+
* {@link KotlinConventions} are applied.
40+
*
3841
* @author Andy Wilkinson
3942
* @author Christoph Dreis
4043
* @author Mike Smithson

buildSrc/src/main/java/org/springframework/boot/build/KotlinConventions.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,9 @@
2525
import org.gradle.api.Project;
2626
import org.gradle.api.tasks.SourceSet;
2727
import org.gradle.api.tasks.SourceSetContainer;
28-
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions;
28+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget;
29+
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions;
30+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion;
2931
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
3032

3133
/**
@@ -35,7 +37,7 @@
3537
* <ul>
3638
* <li>{@link KotlinCompile} tasks are configured to:
3739
* <ul>
38-
* <li>Use {@code apiVersion} and {@code languageVersion} 1.7.
40+
* <li>Use {@code apiVersion} and {@code languageVersion} 2.1.
3941
* <li>Use {@code jvmTarget} 17.
4042
* <li>Treat all warnings as errors
4143
* <li>Suppress version warnings
@@ -56,14 +58,14 @@ void apply(Project project) {
5658
}
5759

5860
private void configure(KotlinCompile compile) {
59-
KotlinJvmOptions kotlinOptions = compile.getKotlinOptions();
60-
kotlinOptions.setApiVersion("1.7");
61-
kotlinOptions.setLanguageVersion("1.7");
62-
kotlinOptions.setJvmTarget("17");
63-
kotlinOptions.setAllWarningsAsErrors(true);
64-
List<String> freeCompilerArgs = new ArrayList<>(kotlinOptions.getFreeCompilerArgs());
61+
KotlinJvmCompilerOptions kotlinOptions = compile.getCompilerOptions();
62+
kotlinOptions.getApiVersion().set(KotlinVersion.KOTLIN_2_1);
63+
kotlinOptions.getLanguageVersion().set(KotlinVersion.KOTLIN_2_1);
64+
kotlinOptions.getJvmTarget().set(JvmTarget.JVM_17);
65+
kotlinOptions.getAllWarningsAsErrors().set(true);
66+
List<String> freeCompilerArgs = new ArrayList<>(kotlinOptions.getFreeCompilerArgs().get());
6567
freeCompilerArgs.add("-Xsuppress-version-warnings");
66-
kotlinOptions.setFreeCompilerArgs(freeCompilerArgs);
68+
kotlinOptions.getFreeCompilerArgs().set(freeCompilerArgs);
6769
}
6870

6971
private void configureDokkatoo(Project project) {

buildSrc/src/main/resources/org/springframework/boot/build/antora/antora-asciidoc-attributes.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# === INCLUDE-CODE LOCATIONS ===
22

33
include-java=ROOT:example$java/org/springframework/boot/docs
4-
include-kotlin= ROOT:example$kotlin/org/springframework/boot/docs
4+
include-kotlin= ROOT:example$kotlin/org/springframework/boot/docs/kotlin
55

66
# === URLs ===
77

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ hamcrestVersion=3.0
1414
jacksonVersion=2.18.2
1515
javaFormatVersion=0.0.43
1616
junitJupiterVersion=5.11.4
17-
kotlinVersion=1.9.25
17+
kotlinVersion=2.1.10
1818
mavenVersion=3.9.4
1919
mockitoVersion=5.15.2
2020
nativeBuildToolsVersion=0.10.5

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,9 @@ bom {
11931193
}
11941194
library("Kotlin", "${kotlinVersion}") {
11951195
prohibit {
1196-
versionRange "[2.0.0-Beta1,)"
1197-
because "it exceeds our baseline"
1196+
contains "-Beta"
1197+
contains "-RC"
1198+
because "we don't want betas or release candidates"
11981199
}
11991200
group("org.jetbrains.kotlin") {
12001201
imports = [

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/cassandra/connecting/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
package org.springframework.boot.docs.data.nosql.cassandra.connecting;
1818

19-
class User {
19+
public class User {
2020

2121
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/Server.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.usingannotatedtypes;
1818

19-
class Server {
19+
public class Server {
2020

21-
Server(Object remoteAddress) {
21+
public Server(Object remoteAddress) {
2222
}
2323

24-
void start() {
24+
public void start() {
2525
}
2626

2727
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/CacheCompletelyBrokenException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
package org.springframework.boot.docs.features.springapplication.applicationavailability.managing;
1818

19-
class CacheCompletelyBrokenException extends RuntimeException {
19+
public class CacheCompletelyBrokenException extends RuntimeException {
2020

2121
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyErrorBody.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
package org.springframework.boot.docs.web.servlet.springmvc.errorhandling;
1818

19-
class MyErrorBody {
19+
public class MyErrorBody {
2020

21-
MyErrorBody(int value, String message) {
21+
public MyErrorBody(int value, String message) {
2222
}
2323

2424
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
package org.springframework.boot.docs.web.servlet.springmvc.errorhandling;
1818

19-
class MyException extends RuntimeException {
19+
public class MyException extends RuntimeException {
2020

2121
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/SomeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
package org.springframework.boot.docs.web.servlet.springmvc.errorhandling;
1818

19-
class SomeController {
19+
public class SomeController {
2020

2121
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.cloudfoundry.customcontextpath
17+
package org.springframework.boot.docs.kotlin.actuator.cloudfoundry.customcontextpath
1818

1919
import jakarta.servlet.GenericServlet
2020
import jakarta.servlet.Servlet
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.boot.docs.actuator.cloudfoundry.customcontextpath
16+
package org.springframework.boot.docs.kotlin.actuator.cloudfoundry.customcontextpath
1717

1818
import org.springframework.boot.autoconfigure.web.reactive.WebFluxProperties
1919
import org.springframework.boot.context.properties.EnableConfigurationProperties
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.endpoints.health.reactivehealthindicators
17+
package org.springframework.boot.docs.kotlin.actuator.endpoints.health.reactivehealthindicators
1818

1919
import org.springframework.boot.actuate.health.Health
2020
import org.springframework.boot.actuate.health.ReactiveHealthIndicator
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.endpoints.health.writingcustomhealthindicators
17+
package org.springframework.boot.docs.kotlin.actuator.endpoints.health.writingcustomhealthindicators
1818

1919
import org.springframework.boot.actuate.health.Health
2020
import org.springframework.boot.actuate.health.HealthIndicator
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.endpoints.implementingcustom
17+
package org.springframework.boot.docs.kotlin.actuator.endpoints.implementingcustom
1818

1919
class CustomData(val name: String, val counter: Int)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.endpoints.implementingcustom
17+
package org.springframework.boot.docs.kotlin.actuator.endpoints.implementingcustom
1818

1919
import org.springframework.boot.actuate.endpoint.annotation.Endpoint
2020
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.endpoints.info.writingcustominfocontributors
17+
package org.springframework.boot.docs.kotlin.actuator.endpoints.info.writingcustominfocontributors
1818

1919
import org.springframework.boot.actuate.info.Info
2020
import org.springframework.boot.actuate.info.InfoContributor
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.endpoints.security.exposeall
17+
package org.springframework.boot.docs.kotlin.actuator.endpoints.security.exposeall
1818

1919
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
2020
import org.springframework.context.annotation.Bean
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.endpoints.security.typical
17+
package org.springframework.boot.docs.kotlin.actuator.endpoints.security.typical
1818

1919
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
2020
import org.springframework.context.annotation.Bean
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.customizing
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.customizing
1818

1919
import io.micrometer.core.instrument.config.MeterFilter
2020
import org.springframework.context.annotation.Bean
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.export.graphite
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.export.graphite
1818

1919
import io.micrometer.core.instrument.Clock
2020
import io.micrometer.core.instrument.Meter
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.export.jmx
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.export.jmx
1818

1919
import io.micrometer.core.instrument.Clock
2020
import io.micrometer.core.instrument.Meter
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.gettingstarted.commontags
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.gettingstarted.commontags
1818

1919
import io.micrometer.core.instrument.MeterRegistry
2020
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.gettingstarted.specifictype
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.gettingstarted.specifictype
1818

1919
import io.micrometer.core.instrument.Meter
2020
import io.micrometer.core.instrument.config.NamingConvention
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.registeringcustom
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.registeringcustom
1818

1919
internal class Dictionary {
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.registeringcustom
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.registeringcustom
1818

1919
import io.micrometer.core.instrument.MeterRegistry
2020
import io.micrometer.core.instrument.Tags
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.registeringcustom
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.registeringcustom
1818

1919
import io.micrometer.core.instrument.Gauge
2020
import io.micrometer.core.instrument.binder.MeterBinder
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.registeringcustom
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.registeringcustom
1818

1919
class Queue {
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.supported.mongodb.command
1818

1919
import com.mongodb.event.CommandEvent
2020
import io.micrometer.core.instrument.Tag
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.supported.mongodb.command
1818

1919
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider
2020
import org.springframework.context.annotation.Bean
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.supported.mongodb.connectionpool
1818

1919
import com.mongodb.event.ConnectionPoolCreatedEvent
2020
import io.micrometer.core.instrument.Tag
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool
17+
package org.springframework.boot.docs.kotlin.actuator.metrics.supported.mongodb.connectionpool
1818

1919
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider
2020
import org.springframework.context.annotation.Bean
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.buildtoolplugins.otherbuildsystems.examplerepackageimplementation
17+
package org.springframework.boot.docs.kotlin.buildtoolplugins.otherbuildsystems.examplerepackageimplementation
1818

1919
import org.springframework.boot.loader.tools.Library
2020
import org.springframework.boot.loader.tools.LibraryCallback
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.configurationmetadata.annotationprocessor.automaticmetadatageneration
17+
package org.springframework.boot.docs.kotlin.configurationmetadata.annotationprocessor.automaticmetadatageneration
1818

1919
import org.springframework.boot.context.properties.ConfigurationProperties
2020
import java.util.Arrays
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.configurationmetadata.annotationprocessor.automaticmetadatageneration
17+
package org.springframework.boot.docs.kotlin.configurationmetadata.annotationprocessor.automaticmetadatageneration
1818

1919
import org.springframework.boot.context.properties.ConfigurationProperties
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.docs.configurationmetadata.annotationprocessor.automaticmetadatageneration.nestedproperties
17+
package org.springframework.boot.docs.kotlin.configurationmetadata.annotationprocessor.automaticmetadatageneration.nestedproperties
1818

1919
import org.springframework.boot.context.properties.ConfigurationProperties
2020

0 commit comments

Comments
 (0)