Configure Kotlin compiler to use -java-parameters by default
See gh-12641
This commit is contained in:
committed by
Andy Wilkinson
parent
404f22e5f9
commit
5e2726f896
@@ -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]]
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension;
|
||||
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
|
||||
@@ -39,6 +40,13 @@ class KotlinPluginAction implements PluginApplicationAction {
|
||||
if (!extraProperties.has("kotlin.version")) {
|
||||
extraProperties.set("kotlin.version", kotlinVersion);
|
||||
}
|
||||
enableJavaParametersOption(project);
|
||||
}
|
||||
|
||||
private void enableJavaParametersOption(Project project) {
|
||||
project.getTasks().withType(KotlinCompile.class, (compile) -> {
|
||||
compile.getKotlinOptions().setJavaParameters(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user