Skip to content

Commit 1f35aba

Browse files
committed
Polish “Configure Kotlin compiler to use -java-parameters by default”
Closes gh-12641
1 parent 5e2726f commit 1f35aba

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,12 @@ JSON request body. When exposed via JMX, the parameters are mapped to the parame
532532
the MBean's operations. Parameters are required by default. They can be made optional
533533
by annotating them with `@org.springframework.lang.Nullable`.
534534

535-
NOTE: To allow the input to be mapped to the operation method's parameters, java code
536-
implementing an endpoint should be compiled with `-parameters`, and kotlin code should
537-
be compiled with `-java-parameters`. This will happen automatically if you are using
538-
Spring Boot's Gradle plugin or if you are using Maven and `spring-boot-starter-parent`.
535+
NOTE: To allow the input to be mapped to the operation method's parameters, Java code
536+
implementing an endpoint should be compiled with `-parameters`, and Kotlin code
537+
implementing an endpoint should be compiled with `-java-parameters`. This will happen
538+
automatically if you are using Spring Boot's Gradle plugin or if you are using Maven and
539+
`spring-boot-starter-parent`.
540+
539541

540542

541543
[[production-ready-endpoints-custom-input-conversion]]

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/reacting.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugin:
2424
the `bootJar` task.
2525
6. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`.
2626
7. Configures any `JavaCompile` tasks to use the `-parameters` compiler argument.
27-
8. Configures any `KotlinCompile` tasks to use the `-java-parameters` compiler argument.
27+
2828

2929

3030
[[reacting-to-other-plugins-kotlin]]
@@ -36,6 +36,7 @@ plugin:
3636
1. Aligns the Kotlin version used in Spring Boot's dependency management with the version
3737
of the plugin. This is achieved by setting the `kotlin.version` property with a value
3838
that matches the version of the Kotlin plugin.
39+
2. Configures any `KotlinCompile` tasks to use the `-java-parameters` compiler argument.
3940

4041

4142

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/KotlinPluginAction.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ public void execute(Project project) {
4444
}
4545

4646
private void enableJavaParametersOption(Project project) {
47-
project.getTasks().withType(KotlinCompile.class, (compile) -> {
48-
compile.getKotlinOptions().setJavaParameters(true);
49-
});
47+
project.getTasks().withType(KotlinCompile.class,
48+
(compile) -> compile.getKotlinOptions().setJavaParameters(true));
5049
}
5150

5251
@Override

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ public void kotlinCompileTasksCanOverrideDefaultJavaParametersFlag() {
6565
.contains("compileKotlin java parameters: false")
6666
.contains("compileTestKotlin java parameters: false");
6767
}
68+
6869
}

0 commit comments

Comments
 (0)