Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
5e2726f8
Commit
5e2726f8
authored
Mar 26, 2018
by
Rui Figueira
Committed by
Andy Wilkinson
Mar 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Configure Kotlin compiler to use -java-parameters by default
See gh-12641
parent
404f22e5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
6 deletions
+74
-6
production-ready-features.adoc
...oot-docs/src/main/asciidoc/production-ready-features.adoc
+4
-5
pom.xml
spring-boot-project/spring-boot-parent/pom.xml
+1
-0
pom.xml
...t/spring-boot-starters/spring-boot-starter-parent/pom.xml
+1
-0
reacting.adoc
...spring-boot-gradle-plugin/src/main/asciidoc/reacting.adoc
+1
-1
KotlinPluginAction.java
...pringframework/boot/gradle/plugin/KotlinPluginAction.java
+8
-0
KotlinPluginActionIntegrationTests.java
...oot/gradle/plugin/KotlinPluginActionIntegrationTests.java
+13
-0
KotlinPluginActionIntegrationTests-kotlinCompileTasksCanOverrideDefaultJavaParametersFlag.gradle
...inCompileTasksCanOverrideDefaultJavaParametersFlag.gradle
+25
-0
KotlinPluginActionIntegrationTests-kotlinCompileTasksUseJavaParametersFlagByDefault.gradle
...s-kotlinCompileTasksUseJavaParametersFlagByDefault.gradle
+21
-0
No files found.
spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
View file @
5e2726f8
...
@@ -532,11 +532,10 @@ JSON request body. When exposed via JMX, the parameters are mapped to the parame
...
@@ -532,11 +532,10 @@ 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
the MBean's operations. Parameters are required by default. They can be made optional
by annotating them with `@org.springframework.lang.Nullable`.
by annotating them with `@org.springframework.lang.Nullable`.
NOTE: To allow the input to be mapped to the operation method's parameters, code
NOTE: To allow the input to be mapped to the operation method's parameters, java code
implementing an endpoint should be compiled with `-parameters`. This will happen
implementing an endpoint should be compiled with `-parameters`, and kotlin code should
automatically if you are using Spring Boot's Gradle plugin or if you are using Maven
be compiled with `-java-parameters`. This will happen automatically if you are using
and `spring-boot-starter-parent`.
Spring Boot's Gradle plugin or if you are using Maven and `spring-boot-starter-parent`.
[[production-ready-endpoints-custom-input-conversion]]
[[production-ready-endpoints-custom-input-conversion]]
...
...
spring-boot-project/spring-boot-parent/pom.xml
View file @
5e2726f8
...
@@ -294,6 +294,7 @@
...
@@ -294,6 +294,7 @@
<jvmTarget>
${java.version}
</jvmTarget>
<jvmTarget>
${java.version}
</jvmTarget>
<apiVersion>
1.1
</apiVersion>
<apiVersion>
1.1
</apiVersion>
<languageVersion>
1.1
</languageVersion>
<languageVersion>
1.1
</languageVersion>
<javaParameters>
true
</javaParameters>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
...
...
spring-boot-project/spring-boot-starters/spring-boot-starter-parent/pom.xml
View file @
5e2726f8
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
<version>
${kotlin.version}
</version>
<version>
${kotlin.version}
</version>
<configuration>
<configuration>
<jvmTarget>
${java.version}
</jvmTarget>
<jvmTarget>
${java.version}
</jvmTarget>
<javaParameters>
true
</javaParameters>
</configuration>
</configuration>
<executions>
<executions>
<execution>
<execution>
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/reacting.adoc
View file @
5e2726f8
...
@@ -24,7 +24,7 @@ plugin:
...
@@ -24,7 +24,7 @@ plugin:
the `bootJar` task.
the `bootJar` task.
6. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`.
6. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`.
7. Configures any `JavaCompile` tasks to use the `-parameters` compiler argument.
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]]
[[reacting-to-other-plugins-kotlin]]
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/KotlinPluginAction.java
View file @
5e2726f8
...
@@ -20,6 +20,7 @@ import org.gradle.api.Plugin;
...
@@ -20,6 +20,7 @@ import org.gradle.api.Plugin;
import
org.gradle.api.Project
;
import
org.gradle.api.Project
;
import
org.gradle.api.plugins.ExtraPropertiesExtension
;
import
org.gradle.api.plugins.ExtraPropertiesExtension
;
import
org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
;
import
org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
;
import
org.jetbrains.kotlin.gradle.tasks.KotlinCompile
;
/**
/**
* {@link PluginApplicationAction} that reacts to Kotlin's Gradle plugin being applied by
* {@link PluginApplicationAction} that reacts to Kotlin's Gradle plugin being applied by
...
@@ -39,6 +40,13 @@ class KotlinPluginAction implements PluginApplicationAction {
...
@@ -39,6 +40,13 @@ class KotlinPluginAction implements PluginApplicationAction {
if
(!
extraProperties
.
has
(
"kotlin.version"
))
{
if
(!
extraProperties
.
has
(
"kotlin.version"
))
{
extraProperties
.
set
(
"kotlin.version"
,
kotlinVersion
);
extraProperties
.
set
(
"kotlin.version"
,
kotlinVersion
);
}
}
enableJavaParametersOption
(
project
);
}
private
void
enableJavaParametersOption
(
Project
project
)
{
project
.
getTasks
().
withType
(
KotlinCompile
.
class
,
(
compile
)
->
{
compile
.
getKotlinOptions
().
setJavaParameters
(
true
);
});
}
}
@Override
@Override
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests.java
View file @
5e2726f8
...
@@ -52,4 +52,17 @@ public class KotlinPluginActionIntegrationTests {
...
@@ -52,4 +52,17 @@ public class KotlinPluginActionIntegrationTests {
.
containsPattern
(
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:* -> 1.2.10"
);
.
containsPattern
(
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:* -> 1.2.10"
);
}
}
@Test
public
void
kotlinCompileTasksUseJavaParametersFlagByDefault
()
{
assertThat
(
this
.
gradleBuild
.
build
(
"kotlinCompileTasksJavaParameters"
).
getOutput
())
.
contains
(
"compileKotlin java parameters: true"
)
.
contains
(
"compileTestKotlin java parameters: true"
);
}
@Test
public
void
kotlinCompileTasksCanOverrideDefaultJavaParametersFlag
()
{
assertThat
(
this
.
gradleBuild
.
build
(
"kotlinCompileTasksJavaParameters"
).
getOutput
())
.
contains
(
"compileKotlin java parameters: false"
)
.
contains
(
"compileTestKotlin java parameters: false"
);
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksCanOverrideDefaultJavaParametersFlag.gradle
0 → 100644
View file @
5e2726f8
buildscript
{
dependencies
{
classpath
files
(
pluginClasspath
.
split
(
','
))
}
}
plugins
{
id
'org.jetbrains.kotlin.jvm'
version
'1.2.10'
}
apply
plugin:
'org.springframework.boot'
import
org.jetbrains.kotlin.gradle.dsl.KotlinCompile
tasks
.
withType
(
KotlinCompile
)
{
kotlinOptions
.
javaParameters
=
false
}
task
(
'kotlinCompileTasksJavaParameters'
)
{
doFirst
{
tasks
.
withType
(
KotlinCompile
)
{
println
"$name java parameters: ${kotlinOptions.javaParameters}"
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksUseJavaParametersFlagByDefault.gradle
0 → 100644
View file @
5e2726f8
buildscript
{
dependencies
{
classpath
files
(
pluginClasspath
.
split
(
','
))
}
}
plugins
{
id
'org.jetbrains.kotlin.jvm'
version
'1.2.10'
}
apply
plugin:
'org.springframework.boot'
import
org.jetbrains.kotlin.gradle.dsl.KotlinCompile
task
(
'kotlinCompileTasksJavaParameters'
)
{
doFirst
{
tasks
.
withType
(
KotlinCompile
)
{
println
"$name java parameters: ${kotlinOptions.javaParameters}"
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment