[Gradle] Fix tryK2 was not applied to Kotlin/JS gradle plugin

^KT-61193 Fixed
This commit is contained in:
Yahor Berdnikau
2023-08-22 17:49:30 +02:00
committed by Space Team
parent c42d19f0e5
commit 7d48a7934f
2 changed files with 48 additions and 0 deletions
@@ -259,6 +259,50 @@ class TryK2IT : KGPBaseTest() {
}
}
@DisplayName("JS: language version default is changed to 2.0")
@JsGradlePluginTests
@GradleTest
fun jsLanguageVersionK2(gradleVersion: GradleVersion) {
project(
"kotlin-js-nodejs-project",
gradleVersion,
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
) {
enableTryK2()
build(":compileKotlinJs") {
assertTasksExecuted(":compileKotlinJs")
assertCompilerArgument(":compileKotlinJs", "-language-version 2.0")
}
}
}
@DisplayName("JS: tryK2 report is produced")
@JsGradlePluginTests
@GradleTest
fun jsTryReport(gradleVersion: GradleVersion) {
project(
"kotlin-js-nodejs-project",
gradleVersion,
) {
enableTryK2()
build("build") {
assertOutputContains(
"""
|##### 'kotlin.experimental.tryK2' results #####
|:compileKotlinJs: 2.0 language version
|:compileProductionExecutableKotlinJs: 2.0 language version
|:compileTestKotlinJs: 2.0 language version
|:compileTestDevelopmentExecutableKotlinJs: 2.0 language version
|##### 100% (4/4) tasks have been compiled with Kotlin 2.0 #####
""".trimMargin().normalizeLineEndings()
)
}
}
}
private fun TestProject.enableTryK2() = gradleProperties.appendText(
"""
|
@@ -92,5 +92,9 @@ open class KotlinJsPlugin: Plugin<Project> {
// Also create predefined source sets
kotlinExtension.sourceSets.maybeCreate(MAIN_COMPILATION_NAME)
kotlinExtension.sourceSets.maybeCreate(TEST_COMPILATION_NAME)
kotlinExtension.registerTargetObserver { target ->
target?.compilerOptions?.configureExperimentalTryK2(project)
}
}
}