Remove 'jdkHome' option from Gradle options
Toolchain feature is replaced it. ^KT-46541 Fixed
This commit is contained in:
-6
@@ -30,12 +30,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value = "-include-runtime", description = "Include Kotlin runtime into the resulting JAR")
|
||||
var includeRuntime: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleDeprecatedOption(
|
||||
message = "This option is not working well with Gradle caching and will be removed in the future.",
|
||||
removeAfter = "1.7",
|
||||
level = DeprecationLevel.WARNING
|
||||
)
|
||||
@GradleOption(DefaultValues.StringNullDefault::class)
|
||||
@Argument(
|
||||
value = "-jdk-home",
|
||||
valueDescription = "<path>",
|
||||
|
||||
-7
@@ -11,13 +11,6 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption
|
||||
*/
|
||||
var javaParameters: kotlin.Boolean
|
||||
|
||||
/**
|
||||
* Include a custom JDK from the specified location into the classpath instead of the default JAVA_HOME
|
||||
* Default value: null
|
||||
*/
|
||||
@Deprecated(message = "This option is not working well with Gradle caching and will be removed in the future.", level = DeprecationLevel.WARNING)
|
||||
var jdkHome: kotlin.String?
|
||||
|
||||
/**
|
||||
* Target version of the generated JVM bytecode (1.6 (DEPRECATED), 1.8, 9, 10, ..., 18), default is 1.8
|
||||
* Possible values: "1.6", "1.8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"
|
||||
|
||||
-27
@@ -28,7 +28,6 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
||||
gradleVersion = gradleVersion
|
||||
) {
|
||||
build("assemble") {
|
||||
assertOutputDoesNotContain("'kotlinOptions.jdkHome' is deprecated and will be ignored in Kotlin 1.7!")
|
||||
assertJdkHomeIsUsingJdk(getUserJdk().javaHomeRealPath)
|
||||
}
|
||||
}
|
||||
@@ -304,32 +303,6 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("User provided jdkHome Kotlin option should produce deprecation warning on Gradle builds")
|
||||
@GradleTest
|
||||
internal fun jdkHomeIsDeprecated(gradleVersion: GradleVersion) {
|
||||
project(
|
||||
projectName = "simple".fullProjectName,
|
||||
gradleVersion = gradleVersion
|
||||
) {
|
||||
//language=Groovy
|
||||
buildGradle.append(
|
||||
"""
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||
|
||||
tasks.withType(KotlinCompile).configureEach {
|
||||
kotlinOptions {
|
||||
jdkHome = "${getJdk9Path()}"
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
build("assemble") {
|
||||
assertJdkHomeIsUsingJdk(getJdk9().javaHomeRealPath)
|
||||
assertOutputContains("'kotlinOptions.jdkHome' is deprecated and will be ignored in Kotlin 1.7!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Should allow to set JDK version for tasks via Java toolchain")
|
||||
@GradleTestVersions
|
||||
@GradleTest
|
||||
|
||||
-11
@@ -95,17 +95,6 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("Should use custom JDK to compile sources")
|
||||
fun testCustomJdk(gradleVersion: GradleVersion) {
|
||||
project("customJdk", gradleVersion) {
|
||||
buildAndFail("build") {
|
||||
assertOutputContains("Unresolved reference: stream")
|
||||
assertOutputDoesNotContain("Unresolved reference: AutoCloseable")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("Compile task destination dir should be configured on configuration phase")
|
||||
fun testDestinationDirReferencedDuringEvaluation(gradleVersion: GradleVersion) {
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin {
|
||||
srcDir 'src'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jdkHome = System.getenv("JDK_17")
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// available in JDK 1.7
|
||||
fun java.lang.AutoCloseable.silentClose() {
|
||||
|
||||
}
|
||||
|
||||
// available in JDK 1.8, should be an error with JDK 1.7
|
||||
fun <T> java.util.stream.Stream<T>.count(): Int {
|
||||
return 0
|
||||
}
|
||||
-5
@@ -44,9 +44,6 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
|
||||
javaParametersField = value
|
||||
}
|
||||
|
||||
@Deprecated(message = "This option is not working well with Gradle caching and will be removed in the future.", level = DeprecationLevel.WARNING)
|
||||
override var jdkHome: kotlin.String? = null
|
||||
|
||||
override var jvmTarget: kotlin.String? = null
|
||||
|
||||
override var moduleName: kotlin.String? = null
|
||||
@@ -73,7 +70,6 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
|
||||
languageVersion?.let { args.languageVersion = it }
|
||||
useFirField?.let { args.useFir = it }
|
||||
javaParametersField?.let { args.javaParameters = it }
|
||||
jdkHome?.let { args.jdkHome = it }
|
||||
jvmTarget?.let { args.jvmTarget = it }
|
||||
moduleName?.let { args.moduleName = it }
|
||||
noJdkField?.let { args.noJdk = it }
|
||||
@@ -89,7 +85,6 @@ internal fun org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments.fi
|
||||
languageVersion = null
|
||||
useFir = false
|
||||
javaParameters = false
|
||||
jdkHome = null
|
||||
jvmTarget = null
|
||||
moduleName = null
|
||||
noJdk = false
|
||||
|
||||
-44
@@ -103,50 +103,6 @@ internal open class KotlinJvmCompilerArgumentsContributor(
|
||||
}
|
||||
args.destinationAsFile = destinationDir
|
||||
|
||||
warnJdkHomeNotUsed(kotlinOptions)
|
||||
|
||||
kotlinOptions.forEach { it.updateArguments(args) }
|
||||
}
|
||||
|
||||
private fun warnJdkHomeNotUsed(kotlinOptions: List<KotlinJvmOptionsImpl>) {
|
||||
kotlinOptions
|
||||
.firstOrNull {
|
||||
@Suppress("DEPRECATION")
|
||||
it.jdkHome != null
|
||||
}
|
||||
?.run {
|
||||
logger.warn(
|
||||
"""
|
||||
'kotlinOptions.jdkHome' is deprecated and will be ignored in Kotlin 1.7!
|
||||
|
||||
Consider using JavaToolchain on Gradle 6.7+:
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(<MAJOR_JDK_VERSION>))
|
||||
}
|
||||
}
|
||||
|
||||
Or on older versions of Gradle:
|
||||
- Kotlin DSL:
|
||||
project.tasks
|
||||
.withType<UsesKotlinJavaToolchain>()
|
||||
.configureEach {
|
||||
it.kotlinJavaToolchain.jdk.use(
|
||||
"/path/to/your/jdk",
|
||||
JavaVersion.<JDK_VERSION>
|
||||
)
|
||||
}
|
||||
- Groovy DSL
|
||||
project.tasks
|
||||
.withType(UsesKotlinJavaToolchain.class)
|
||||
.configureEach {
|
||||
it.kotlinJavaToolchain.jdk.use(
|
||||
'/path/to/your/jdk',
|
||||
JavaVersion.<JDK_VERSION>
|
||||
)
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user