From 1f35abacd6958ecf4f68a30ed6dc072f1fec71cf Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 28 Mar 2018 12:21:22 +0100 Subject: [PATCH] =?UTF-8?q?Polish=20=E2=80=9CConfigure=20Kotlin=20compiler?= =?UTF-8?q?=20to=20use=20-java-parameters=20by=20default=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes gh-12641 --- .../src/main/asciidoc/production-ready-features.adoc | 10 ++++++---- .../src/main/asciidoc/reacting.adoc | 3 ++- .../boot/gradle/plugin/KotlinPluginAction.java | 5 ++--- .../plugin/KotlinPluginActionIntegrationTests.java | 1 + 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 3092da2d73..c9e637ee91 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -532,10 +532,12 @@ JSON request body. When exposed via JMX, the parameters are mapped to the parame the MBean's operations. Parameters are required by default. They can be made optional by annotating them with `@org.springframework.lang.Nullable`. -NOTE: To allow the input to be mapped to the operation method's parameters, java code -implementing an endpoint should be compiled with `-parameters`, and kotlin code should -be compiled with `-java-parameters`. This will happen automatically if you are using -Spring Boot's Gradle plugin or if you are using Maven and `spring-boot-starter-parent`. +NOTE: To allow the input to be mapped to the operation method's parameters, Java code +implementing an endpoint should be compiled with `-parameters`, and Kotlin code +implementing an endpoint should be compiled with `-java-parameters`. This will happen +automatically if you are using Spring Boot's Gradle plugin or if you are using Maven and +`spring-boot-starter-parent`. + [[production-ready-endpoints-custom-input-conversion]] diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/reacting.adoc b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/reacting.adoc index 063d55b459..e7c730f9f5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/reacting.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/reacting.adoc @@ -24,7 +24,7 @@ plugin: the `bootJar` task. 6. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`. 7. Configures any `JavaCompile` tasks to use the `-parameters` compiler argument. -8. Configures any `KotlinCompile` tasks to use the `-java-parameters` compiler argument. + [[reacting-to-other-plugins-kotlin]] @@ -36,6 +36,7 @@ plugin: 1. Aligns the Kotlin version used in Spring Boot's dependency management with the version of the plugin. This is achieved by setting the `kotlin.version` property with a value that matches the version of the Kotlin plugin. +2. Configures any `KotlinCompile` tasks to use the `-java-parameters` compiler argument. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/KotlinPluginAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/KotlinPluginAction.java index 700c5ce6d3..65dd533974 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/KotlinPluginAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/KotlinPluginAction.java @@ -44,9 +44,8 @@ class KotlinPluginAction implements PluginApplicationAction { } private void enableJavaParametersOption(Project project) { - project.getTasks().withType(KotlinCompile.class, (compile) -> { - compile.getKotlinOptions().setJavaParameters(true); - }); + project.getTasks().withType(KotlinCompile.class, + (compile) -> compile.getKotlinOptions().setJavaParameters(true)); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests.java index 97b8322c5f..fcb5356d3a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests.java @@ -65,4 +65,5 @@ public class KotlinPluginActionIntegrationTests { .contains("compileKotlin java parameters: false") .contains("compileTestKotlin java parameters: false"); } + }