Fix users could not configure task using deprecated dsl.KotlinJvmOptions

^KT-52239
This commit is contained in:
Yahor Berdnikau
2022-05-02 11:22:41 +02:00
committed by Space
parent cfd11f2075
commit e4c84032e1
4 changed files with 37 additions and 2 deletions
@@ -215,6 +215,28 @@ class KotlinGradleIT : KGPBaseTest() {
}
}
@DisplayName("KT-52239: Changing Kotlin options via deprecated 'dsl.KotlinJvmOptions' interface")
@GradleTest
fun testKotlinOptionsViaDeprecatedKotlinJvmOptionsDsl(gradleVersion: GradleVersion) {
project("kotlinProject", gradleVersion) {
val customModuleName = "custom_module_name"
buildGradle.appendText(
//language=Groovy
"""
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile.class).configureEach {
kotlinOptions.moduleName = "$customModuleName"
}
""".trimIndent()
)
build("assemble") {
assertFileExists(kotlinClassesDir().resolve("META-INF/$customModuleName.kotlin_module"))
}
}
}
@DisplayName("Downgrading Kotlin plugin version")
@GradleTest
fun testDowngradePluginVersion(gradleVersion: GradleVersion) {
@@ -20,6 +20,7 @@ import groovy.lang.Closure
import org.gradle.api.Task
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile as KotlinJvmCompileApi
interface KotlinJsCompile : KotlinCompile<KotlinJsOptions>
@@ -27,7 +28,7 @@ interface KotlinJsCompile : KotlinCompile<KotlinJsOptions>
message = "Moved into API artifact",
replaceWith = ReplaceWith("KotlinJvmCompile", "org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile")
)
interface KotlinJvmCompile : KotlinCompile<KotlinJvmOptions>
interface KotlinJvmCompile : KotlinJvmCompileApi
interface KotlinCommonCompile : KotlinCompile<KotlinMultiplatformCommonOptions>
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.tasks
/**
* Workaround for deprecation warning in import.
*/
@Suppress("DEPRECATION")
typealias KotlinJvmCompileDsl = org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
@@ -506,7 +506,7 @@ abstract class KotlinCompile @Inject constructor(
workerExecutor: WorkerExecutor,
private val objectFactory: ObjectFactory
) : AbstractKotlinCompile<K2JVMCompilerArguments>(objectFactory),
KotlinJvmCompile,
@Suppress("TYPEALIAS_EXPANSION_DEPRECATION") KotlinJvmCompileDsl,
UsesKotlinJavaToolchain {
/** A package prefix that is used for locating Java sources in a directory structure with non-full-depth packages.