From c6c98182850522af029dd5a94fe4053e18aa204d Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Mon, 14 Oct 2019 11:30:08 +0200 Subject: [PATCH 1/2] Update Kotlin-related reference documentation See gh-18573 --- .../main/asciidoc/spring-boot-features.adoc | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 5383cc88c3..c0e71127a4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -7614,35 +7614,44 @@ In order to avoid mixing different versions of Kotlin dependencies on the classp With Maven, the Kotlin version can be customized via the `kotlin.version` property and plugin management is provided for `kotlin-maven-plugin`. With Gradle, the Spring Boot plugin automatically aligns the `kotlin.version` with the version of the Kotlin plugin. +Spring Boot also manages the version of Coroutines dependencies by importing Kotlin +Coroutines BOM, which can be customized via the `kotlin-coroutines.version` property. + +TIP: `org.jetbrains.kotlinx:kotlinx-coroutines-reactor` dependency is provided by default +if one bootstraps a Kotlin project with at least one Reactive dependency on https://start.spring.io/#!language=kotlin[start.spring.io]. [[boot-features-kotlin-configuration-properties]] === `@ConfigurationProperties` -`@ConfigurationProperties` supports classes with immutable `val` properties as shown in the following example: +`@ConfigurationProperties` when used in combination with `@ConstructorBinding` (see the +<> for more details) +supports classes with immutable `val` properties as shown in the following example: [source,kotlin,indent=0] ---- @ConfigurationProperties("example.kotlin") +@ConstructorBinding data class KotlinExampleProperties( val name: String, val description: String, - val myService: MyService -) + val myService: MyService) { -data class MyService( - val apiToken: String, - val uri: URI -) + data class MyService( + val apiToken: String, + val uri: URI + ) +} ---- TIP: To generate <> using the annotation processor, {kotlin-docs}kapt.html[`kapt` should be configured] with the `spring-boot-configuration-processor` dependency. -Note that some features (such as detecting the default value or deperecated items) are not working due to limitations in the model kapt provides. +Note that some features (such as detecting the default value or deprecated items) are not working due to limitations in the model kapt provides. [[boot-features-kotlin-testing]] === Testing -While it is possible to use JUnit 4 to test Kotlin code, JUnit 5 is recommended. +While it is possible to use JUnit 4 to test Kotlin code, JUnit 5 now provided by default +with Spring Boot is recommended. JUnit 5 enables a test class to be instantiated once and reused for all of the class's tests. This makes it possible to use `@BeforeClass` and `@AfterClass` annotations on non-static methods, which is a good fit for Kotlin. @@ -7683,6 +7692,7 @@ If you need the `Mockk` equivalent of the Mockito specific < Date: Mon, 14 Oct 2019 11:41:03 +0100 Subject: [PATCH 2/2] Polish "Update Kotlin-related reference documentation" See gh-18573 --- .../src/main/asciidoc/spring-boot-features.adoc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index c0e71127a4..06d62c7f96 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -7614,23 +7614,20 @@ In order to avoid mixing different versions of Kotlin dependencies on the classp With Maven, the Kotlin version can be customized via the `kotlin.version` property and plugin management is provided for `kotlin-maven-plugin`. With Gradle, the Spring Boot plugin automatically aligns the `kotlin.version` with the version of the Kotlin plugin. -Spring Boot also manages the version of Coroutines dependencies by importing Kotlin -Coroutines BOM, which can be customized via the `kotlin-coroutines.version` property. +Spring Boot also manages the version of Coroutines dependencies by importing the Kotlin Coroutines BOM. +The version can be customized via the `kotlin-coroutines.version` property. -TIP: `org.jetbrains.kotlinx:kotlinx-coroutines-reactor` dependency is provided by default -if one bootstraps a Kotlin project with at least one Reactive dependency on https://start.spring.io/#!language=kotlin[start.spring.io]. +TIP: `org.jetbrains.kotlinx:kotlinx-coroutines-reactor` dependency is provided by default if one bootstraps a Kotlin project with at least one reactive dependency on https://start.spring.io/#!language=kotlin[start.spring.io]. [[boot-features-kotlin-configuration-properties]] === `@ConfigurationProperties` -`@ConfigurationProperties` when used in combination with `@ConstructorBinding` (see the -<> for more details) -supports classes with immutable `val` properties as shown in the following example: +`@ConfigurationProperties` when used in combination with <> supports classes with immutable `val` properties as shown in the following example: [source,kotlin,indent=0] ---- -@ConfigurationProperties("example.kotlin") @ConstructorBinding +@ConfigurationProperties("example.kotlin") data class KotlinExampleProperties( val name: String, val description: String, @@ -7650,8 +7647,7 @@ Note that some features (such as detecting the default value or deprecated items [[boot-features-kotlin-testing]] === Testing -While it is possible to use JUnit 4 to test Kotlin code, JUnit 5 now provided by default -with Spring Boot is recommended. +While it is possible to use JUnit 4 to test Kotlin code, JUnit 5 is provided by default and is recommended. JUnit 5 enables a test class to be instantiated once and reused for all of the class's tests. This makes it possible to use `@BeforeClass` and `@AfterClass` annotations on non-static methods, which is a good fit for Kotlin.