[Gradle] Repurpose 'kotlin.experimental.tryK2'
Now it sets +1 to default one language version. Property name was updated to 'kotlin.experimental.tryNext'. ^KT-61975 Fixed
This commit is contained in:
committed by
Space Team
parent
4efe7a00f1
commit
294b36e16f
+74
-70
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle.experimental
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.parseCompilerArgumentsFromBuildOutput
|
||||
@@ -15,8 +16,8 @@ import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import kotlin.io.path.appendText
|
||||
|
||||
@DisplayName("'kotlin.experimental.tryK2' option")
|
||||
class TryK2IT : KGPBaseTest() {
|
||||
@DisplayName("'kotlin.experimental.tryNext' option")
|
||||
class TryNextIT : KGPBaseTest() {
|
||||
|
||||
@DisplayName("Produces single warning message in multi-project when enabled")
|
||||
@JvmGradlePluginTests
|
||||
@@ -27,16 +28,16 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.WARN)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build("--dry-run") {
|
||||
output.assertHasDiagnostic(KotlinToolingDiagnostics.ExperimentalK2Warning)
|
||||
output.assertHasDiagnostic(KotlinToolingDiagnostics.ExperimentalTryNextWarning)
|
||||
assertOutputContains("No Kotlin compilation tasks have been run")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("JVM: language version default is changed to 2.0")
|
||||
@DisplayName("JVM: language version default is changed to next")
|
||||
@JvmGradlePluginTests
|
||||
@GradleTest
|
||||
fun languageVersionChanged(gradleVersion: GradleVersion) {
|
||||
@@ -45,12 +46,12 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build("compileKotlin") {
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
|
||||
assertCompilerArgument(":compileKotlin", "-language-version 2.0")
|
||||
assertCompilerArgument(":compileKotlin", "-language-version $nextKotlinLanguageVersion")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +67,7 @@ class TryK2IT : KGPBaseTest() {
|
||||
) {
|
||||
build("build") {
|
||||
assertOutputDoesNotContain(
|
||||
"##### 'kotlin.experimental.tryK2' results #####"
|
||||
"##### 'kotlin.experimental.tryNext' results #####"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -81,15 +82,15 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.WARN)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build("build") {
|
||||
assertOutputContains(
|
||||
"""
|
||||
|##### 'kotlin.experimental.tryK2' results #####
|
||||
|:app:compileKotlin: 2.0 language version
|
||||
|:lib:compileKotlin: 2.0 language version
|
||||
|##### 100% (2/2) tasks have been compiled with Kotlin 2.0 #####
|
||||
|##### 'kotlin.experimental.tryNext' results #####
|
||||
|:app:compileKotlin: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileKotlin: $nextKotlinLanguageVersion language version
|
||||
|##### 100% (2/2) tasks have been compiled with Kotlin $nextKotlinLanguageVersion #####
|
||||
""".trimMargin().normalizeLineEndings()
|
||||
)
|
||||
}
|
||||
@@ -105,21 +106,22 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.WARN)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build("build") {
|
||||
assertOutputContains(
|
||||
"""
|
||||
|##### 'kotlin.experimental.tryK2' results #####
|
||||
|:compileCommonMainKotlinMetadata: 2.0 language version
|
||||
|:compileKotlinLinuxX64: 2.0 language version${
|
||||
|##### 'kotlin.experimental.tryNext' results #####
|
||||
|:compileCommonMainKotlinMetadata: $nextKotlinLanguageVersion language version
|
||||
|:compileKotlinLinuxX64: $nextKotlinLanguageVersion language version${
|
||||
if (HostManager.hostIsMac)
|
||||
"\n|:compileKotlinMacosArm64: 2.0 language version\n|:compileKotlinMacosX64: 2.0 language version"
|
||||
"\n|:compileKotlinMacosArm64: $nextKotlinLanguageVersion language version\n" +
|
||||
"|:compileKotlinMacosX64: $nextKotlinLanguageVersion language version"
|
||||
else ""
|
||||
}
|
||||
|:compileKotlinMingwX64: 2.0 language version
|
||||
|:compileNativeMainKotlinMetadata: 2.0 language version
|
||||
|##### 100% ${if (HostManager.hostIsMac) "(6/6)" else "(4/4)"} tasks have been compiled with Kotlin 2.0 #####
|
||||
|:compileKotlinMingwX64: $nextKotlinLanguageVersion language version
|
||||
|:compileNativeMainKotlinMetadata: $nextKotlinLanguageVersion language version
|
||||
|##### 100% ${if (HostManager.hostIsMac) "(6/6)" else "(4/4)"} tasks have been compiled with Kotlin $nextKotlinLanguageVersion #####
|
||||
""".trimMargin().normalizeLineEndings()
|
||||
)
|
||||
}
|
||||
@@ -135,7 +137,7 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.WARN)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
subProject("app").kotlinSourcesDir().resolve("foo/AA.kt").appendText(
|
||||
"""
|
||||
@@ -147,17 +149,17 @@ class TryK2IT : KGPBaseTest() {
|
||||
buildAndFail("build") {
|
||||
assertOutputContains(
|
||||
"""
|
||||
|##### 'kotlin.experimental.tryK2' results #####
|
||||
|:app:compileKotlin: 2.0 language version
|
||||
|:lib:compileKotlin: 2.0 language version
|
||||
|##### 100% (2/2) tasks have been compiled with Kotlin 2.0 #####
|
||||
|##### 'kotlin.experimental.tryNext' results #####
|
||||
|:app:compileKotlin: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileKotlin: $nextKotlinLanguageVersion language version
|
||||
|##### 100% (2/2) tasks have been compiled with Kotlin $nextKotlinLanguageVersion #####
|
||||
""".trimMargin().normalizeLineEndings()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("MPP: language version default is changed to 2.0")
|
||||
@DisplayName("MPP: language version default is changed to next")
|
||||
@MppGradlePluginTests
|
||||
@GradleTest
|
||||
fun languageVersionChangedMpp(gradleVersion: GradleVersion) {
|
||||
@@ -166,30 +168,30 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build(":compileCommonMainKotlinMetadata") {
|
||||
assertTasksExecuted(":compileCommonMainKotlinMetadata")
|
||||
|
||||
assertCompilerArgument(":compileCommonMainKotlinMetadata", "-language-version 2.0")
|
||||
assertCompilerArgument(":compileCommonMainKotlinMetadata", "-language-version $nextKotlinLanguageVersion")
|
||||
}
|
||||
|
||||
build(":compileKotlinJvm") {
|
||||
assertTasksExecuted(":compileKotlinJvm")
|
||||
|
||||
assertCompilerArgument(":compileKotlinJvm", "-language-version 2.0")
|
||||
assertCompilerArgument(":compileKotlinJvm", "-language-version $nextKotlinLanguageVersion")
|
||||
}
|
||||
|
||||
build(":compileKotlinJs") {
|
||||
assertTasksExecuted(":compileKotlinJs")
|
||||
|
||||
assertCompilerArgument(":compileKotlinJs", "-language-version 2.0")
|
||||
assertCompilerArgument(":compileKotlinJs", "-language-version $nextKotlinLanguageVersion")
|
||||
}
|
||||
|
||||
build(":compileKotlinWasmJs") {
|
||||
assertTasksExecuted(":compileKotlinWasmJs")
|
||||
|
||||
assertCompilerArgument(":compileKotlinWasmJs", "-language-version 2.0")
|
||||
assertCompilerArgument(":compileKotlinWasmJs", "-language-version $nextKotlinLanguageVersion")
|
||||
}
|
||||
|
||||
build(":compileKotlinLinuxX64") {
|
||||
@@ -197,14 +199,14 @@ class TryK2IT : KGPBaseTest() {
|
||||
|
||||
val compileTaskOutput = getOutputForTask(":compileKotlinLinuxX64")
|
||||
val compilerArgs = parseCompilerArgumentsFromBuildOutput(K2NativeCompilerArguments::class, compileTaskOutput)
|
||||
assert(compilerArgs.languageVersion == "2.0") {
|
||||
":compileKotlinLinuxX64 'languageVersion' is not '2.0': ${compilerArgs.languageVersion}"
|
||||
assert(compilerArgs.languageVersion == nextKotlinLanguageVersion) {
|
||||
":compileKotlinLinuxX64 'languageVersion' is not '$nextKotlinLanguageVersion': ${compilerArgs.languageVersion}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("MPP: language version default is changed to 2.0 for metadata compilations")
|
||||
@DisplayName("MPP: language version default is changed to next for metadata compilations")
|
||||
@MppGradlePluginTests
|
||||
@GradleTest
|
||||
fun languageVersionChangedMppMetadata(gradleVersion: GradleVersion) {
|
||||
@@ -213,7 +215,7 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build(":p1:compileAppleAndLinuxMainKotlinMetadata") {
|
||||
assertTasksExecuted(
|
||||
@@ -222,12 +224,12 @@ class TryK2IT : KGPBaseTest() {
|
||||
":p1:compileAppleAndLinuxMainKotlinMetadata",
|
||||
)
|
||||
|
||||
assertCompilerArgument(":p1:compileCommonMainKotlinMetadata", "-language-version 2.0")
|
||||
assertCompilerArgument(":p1:compileConcurrentMainKotlinMetadata", "-language-version 2.0")
|
||||
assertCompilerArgument(":p1:compileCommonMainKotlinMetadata", "-language-version $nextKotlinLanguageVersion")
|
||||
assertCompilerArgument(":p1:compileConcurrentMainKotlinMetadata", "-language-version $nextKotlinLanguageVersion")
|
||||
val taskOutput = getOutputForTask(":p1:compileAppleAndLinuxMainKotlinMetadata")
|
||||
val appleAndLinuxMetadataArgs = parseCompilerArgumentsFromBuildOutput(K2NativeCompilerArguments::class, taskOutput)
|
||||
assert(appleAndLinuxMetadataArgs.languageVersion == "2.0") {
|
||||
":compileAppleAndLinuxMainKotlinMetadata 'languageVersion' is not '2.0': ${appleAndLinuxMetadataArgs.languageVersion}"
|
||||
assert(appleAndLinuxMetadataArgs.languageVersion == nextKotlinLanguageVersion) {
|
||||
":compileAppleAndLinuxMainKotlinMetadata 'languageVersion' is not '$nextKotlinLanguageVersion': ${appleAndLinuxMetadataArgs.languageVersion}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,7 +244,7 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
@@ -259,7 +261,7 @@ class TryK2IT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("JS: language version default is changed to 2.0")
|
||||
@DisplayName("JS: language version default is changed to next")
|
||||
@JsGradlePluginTests
|
||||
@GradleTest
|
||||
fun jsLanguageVersionK2(gradleVersion: GradleVersion) {
|
||||
@@ -268,17 +270,17 @@ class TryK2IT : KGPBaseTest() {
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build(":compileKotlinJs") {
|
||||
assertTasksExecuted(":compileKotlinJs")
|
||||
|
||||
assertCompilerArgument(":compileKotlinJs", "-language-version 2.0")
|
||||
assertCompilerArgument(":compileKotlinJs", "-language-version $nextKotlinLanguageVersion")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("JS: tryK2 report is produced")
|
||||
@DisplayName("JS: tryNext report is produced")
|
||||
@JsGradlePluginTests
|
||||
@GradleTest
|
||||
fun jsTryReport(gradleVersion: GradleVersion) {
|
||||
@@ -286,17 +288,17 @@ class TryK2IT : KGPBaseTest() {
|
||||
"kotlin-js-nodejs-project",
|
||||
gradleVersion,
|
||||
) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
|
||||
build("build") {
|
||||
assertOutputContains(
|
||||
"""
|
||||
|##### 'kotlin.experimental.tryK2' results #####
|
||||
|:compileKotlinJs: 2.0 language version
|
||||
|:compileProductionExecutableKotlinJs: 2.0 language version
|
||||
|:compileTestDevelopmentExecutableKotlinJs: 2.0 language version
|
||||
|:compileTestKotlinJs: 2.0 language version
|
||||
|##### 100% (4/4) tasks have been compiled with Kotlin 2.0 #####
|
||||
|##### 'kotlin.experimental.tryNext' results #####
|
||||
|:compileKotlinJs: $nextKotlinLanguageVersion language version
|
||||
|:compileProductionExecutableKotlinJs: $nextKotlinLanguageVersion language version
|
||||
|:compileTestDevelopmentExecutableKotlinJs: $nextKotlinLanguageVersion language version
|
||||
|:compileTestKotlinJs: $nextKotlinLanguageVersion language version
|
||||
|##### 100% (4/4) tasks have been compiled with Kotlin $nextKotlinLanguageVersion #####
|
||||
""".trimMargin().normalizeLineEndings()
|
||||
)
|
||||
}
|
||||
@@ -308,31 +310,31 @@ class TryK2IT : KGPBaseTest() {
|
||||
@GradleTest
|
||||
fun smokeTestForNativeTasks(gradleVersion: GradleVersion) {
|
||||
project("native-configuration-cache", gradleVersion) {
|
||||
enableTryK2()
|
||||
enableTryNext()
|
||||
build("build") {
|
||||
if (HostManager.hostIsMac) {
|
||||
assertOutputContains(
|
||||
"""
|
||||
|##### 'kotlin.experimental.tryK2' results #####
|
||||
|:lib:compileCommonMainKotlinMetadata: 2.0 language version
|
||||
|:lib:compileKotlinIosArm64: 2.0 language version
|
||||
|:lib:compileKotlinIosSimulatorArm64: 2.0 language version
|
||||
|:lib:compileKotlinIosX64: 2.0 language version
|
||||
|:lib:compileKotlinLinuxX64: 2.0 language version
|
||||
|:lib:compileTestKotlinIosSimulatorArm64: 2.0 language version
|
||||
|:lib:compileTestKotlinIosX64: 2.0 language version
|
||||
|:lib:compileTestKotlinLinuxX64: 2.0 language version
|
||||
|##### 100% (8/8) tasks have been compiled with Kotlin 2.0 #####
|
||||
|##### 'kotlin.experimental.tryNext' results #####
|
||||
|:lib:compileCommonMainKotlinMetadata: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileKotlinIosArm64: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileKotlinIosSimulatorArm64: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileKotlinIosX64: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileKotlinLinuxX64: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileTestKotlinIosSimulatorArm64: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileTestKotlinIosX64: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileTestKotlinLinuxX64: $nextKotlinLanguageVersion language version
|
||||
|##### 100% (8/8) tasks have been compiled with Kotlin $nextKotlinLanguageVersion #####
|
||||
""".trimMargin().normalizeLineEndings()
|
||||
)
|
||||
} else {
|
||||
assertOutputContains(
|
||||
"""
|
||||
|##### 'kotlin.experimental.tryK2' results #####
|
||||
|:lib:compileCommonMainKotlinMetadata: 2.0 language version
|
||||
|:lib:compileKotlinLinuxX64: 2.0 language version
|
||||
|:lib:compileTestKotlinLinuxX64: 2.0 language version
|
||||
|##### 100% (3/3) tasks have been compiled with Kotlin 2.0 #####
|
||||
|##### 'kotlin.experimental.tryNext' results #####
|
||||
|:lib:compileCommonMainKotlinMetadata: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileKotlinLinuxX64: $nextKotlinLanguageVersion language version
|
||||
|:lib:compileTestKotlinLinuxX64: $nextKotlinLanguageVersion language version
|
||||
|##### 100% (3/3) tasks have been compiled with Kotlin $nextKotlinLanguageVersion #####
|
||||
""".trimMargin().normalizeLineEndings()
|
||||
)
|
||||
}
|
||||
@@ -340,10 +342,12 @@ class TryK2IT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun TestProject.enableTryK2() = gradleProperties.appendText(
|
||||
private fun TestProject.enableTryNext() = gradleProperties.appendText(
|
||||
"""
|
||||
|
|
||||
|kotlin.experimental.tryK2=true
|
||||
|kotlin.experimental.tryNext=true
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
private val nextKotlinLanguageVersion = KotlinVersion.values().first { it > KotlinVersion.DEFAULT }.version
|
||||
}
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.gradle.plugin.hierarchy.KotlinHierarchyDslImpl
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.targets.android.internal.InternalKotlinTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.targets.android.internal.internal
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
import org.jetbrains.kotlin.gradle.utils.newInstance
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -246,7 +246,7 @@ abstract class KotlinMultiplatformExtension
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
internal val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||
.newInstance<KotlinCommonCompilerOptionsDefault>()
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
.also {
|
||||
syncCommonOptions(it)
|
||||
}
|
||||
|
||||
+3
-5
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.gradle.internal.KOTLIN_BUILD_TOOLS_API_IMPL
|
||||
import org.jetbrains.kotlin.gradle.internal.KOTLIN_MODULE_GROUP
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle.CoroutineStart.Undispatched
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||
@@ -29,9 +28,8 @@ import org.jetbrains.kotlin.gradle.utils.*
|
||||
import org.jetbrains.kotlin.gradle.utils.CompletableFuture
|
||||
import org.jetbrains.kotlin.gradle.utils.Future
|
||||
import org.jetbrains.kotlin.gradle.utils.castIsolatedKotlinPluginClassLoaderAware
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||
import org.jetbrains.kotlin.tooling.core.MutableExtras
|
||||
import org.jetbrains.kotlin.tooling.core.mutableExtrasOf
|
||||
@@ -204,7 +202,7 @@ abstract class KotlinJvmProjectExtension(project: Project) : KotlinSingleJavaTar
|
||||
|
||||
val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||
.newInstance(KotlinJvmCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
|
||||
fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
@@ -337,7 +335,7 @@ abstract class KotlinAndroidProjectExtension(project: Project) : KotlinSingleTar
|
||||
|
||||
val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||
.newInstance(KotlinJvmCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
|
||||
fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.toSingleCompilerPluginOptions
|
||||
import org.jetbrains.kotlin.gradle.utils.classpathAsList
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
import org.jetbrains.kotlin.gradle.utils.destinationAsFile
|
||||
import org.jetbrains.kotlin.gradle.utils.toPathsArray
|
||||
import javax.inject.Inject
|
||||
@@ -49,7 +49,7 @@ abstract class KaptGenerateStubsTask @Inject constructor(
|
||||
) : KotlinCompile(
|
||||
objectFactory
|
||||
.newInstance(KotlinJvmCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project),
|
||||
.configureExperimentalTryNext(project),
|
||||
workerExecutor,
|
||||
objectFactory
|
||||
), KaptGenerateStubs {
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
|
||||
@Deprecated(
|
||||
message = "Should be removed with Js platform plugin",
|
||||
@@ -41,7 +41,7 @@ internal open class Kotlin2JsPlugin(
|
||||
object : HasCompilerOptions<KotlinJsCompilerOptions> {
|
||||
override val options: KotlinJsCompilerOptions = project.objects
|
||||
.newInstance(KotlinJsCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
}
|
||||
},
|
||||
{ compilerOptions: KotlinJsCompilerOptions ->
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.configuration.KaptGenerateStubsConfig
|
||||
import org.jetbrains.kotlin.gradle.tasks.configuration.KaptWithoutKotlincConfig
|
||||
import org.jetbrains.kotlin.gradle.tasks.configuration.KotlinCompileConfig
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
|
||||
/** Plugin that can be used by third-party plugins to create Kotlin-specific DSL and tasks (compilation and KAPT) for JVM platform. */
|
||||
abstract class KotlinBaseApiPlugin : DefaultKotlinBasePlugin(), KotlinJvmFactory {
|
||||
@@ -45,7 +45,7 @@ abstract class KotlinBaseApiPlugin : DefaultKotlinBasePlugin(), KotlinJvmFactory
|
||||
override fun createCompilerJvmOptions(): KotlinJvmCompilerOptions {
|
||||
return myProject.objects
|
||||
.newInstance(KotlinJvmCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(myProject)
|
||||
.configureExperimentalTryNext(myProject)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
|
||||
internal open class KotlinCommonPlugin(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
@@ -37,7 +37,7 @@ internal open class KotlinCommonPlugin(
|
||||
object : HasCompilerOptions<KotlinMultiplatformCommonCompilerOptions> {
|
||||
override val options: KotlinMultiplatformCommonCompilerOptions = project.objects
|
||||
.newInstance(KotlinMultiplatformCommonCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
}
|
||||
},
|
||||
{ compilerOptions: KotlinMultiplatformCommonCompilerOptions ->
|
||||
|
||||
+2
-3
@@ -10,9 +10,8 @@ import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin
|
||||
import org.jetbrains.kotlin.gradle.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
|
||||
const val KOTLIN_DSL_NAME = "kotlin"
|
||||
|
||||
@@ -59,7 +58,7 @@ internal open class KotlinJvmPlugin(
|
||||
override val options: KotlinJvmCompilerOptions =
|
||||
project.objects
|
||||
.newInstance(KotlinJvmCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
}
|
||||
},
|
||||
{ compilerOptions: KotlinJvmCompilerOptions ->
|
||||
|
||||
+4
-4
@@ -19,8 +19,8 @@ import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLI
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_COMPILER_USE_PRECISE_COMPILATION_RESULTS_BACKUP
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_CREATE_ARCHIVE_TASKS_FOR_CUSTOM_COMPILATIONS
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_CREATE_DEFAULT_MULTIPLATFORM_PUBLICATIONS
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_EXPERIMENTAL_TRY_K2
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_INCREMENTAL_USE_CLASSPATH_SNAPSHOT
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_EXPERIMENTAL_TRY_NEXT
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_INTERNAL_DIAGNOSTICS_SHOW_STACKTRACE
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_INTERNAL_DIAGNOSTICS_USE_PARSABLE_FORMATTING
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_JS_KARMA_BROWSERS
|
||||
@@ -480,9 +480,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val allowLegacyMppDependencies: Boolean
|
||||
get() = booleanProperty(KOTLIN_MPP_ALLOW_LEGACY_DEPENDENCIES) ?: false
|
||||
|
||||
val kotlinExperimentalTryK2: Provider<Boolean> = project.providers
|
||||
val kotlinExperimentalTryNext: Provider<Boolean> = project.providers
|
||||
.provider<Boolean> {
|
||||
booleanProperty(KOTLIN_EXPERIMENTAL_TRY_K2)
|
||||
booleanProperty(KOTLIN_EXPERIMENTAL_TRY_NEXT)
|
||||
}
|
||||
.orElse(false)
|
||||
|
||||
@@ -644,7 +644,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val KOTLIN_RUN_COMPILER_VIA_BUILD_TOOLS_API = property("kotlin.compiler.runViaBuildToolsApi")
|
||||
val KOTLIN_MPP_ALLOW_LEGACY_DEPENDENCIES = property("kotlin.mpp.allow.legacy.dependencies")
|
||||
val KOTLIN_PUBLISH_JVM_ENVIRONMENT_ATTRIBUTE = property("kotlin.publishJvmEnvironmentAttribute")
|
||||
val KOTLIN_EXPERIMENTAL_TRY_K2 = property("kotlin.experimental.tryK2")
|
||||
val KOTLIN_EXPERIMENTAL_TRY_NEXT = property("kotlin.experimental.tryNext")
|
||||
val KOTLIN_SUPPRESS_GRADLE_PLUGIN_WARNINGS = property("kotlin.suppressGradlePluginWarnings")
|
||||
val KOTLIN_NATIVE_IGNORE_DISABLED_TARGETS = property("kotlin.native.ignoreDisabledTargets")
|
||||
val KOTLIN_NATIVE_SUPPRESS_EXPERIMENTAL_ARTIFACTS_DSL_WARNING = property("kotlin.native.suppressExperimentalArtifactsDslWarning")
|
||||
|
||||
+2
-3
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.gradle.plugin.diagnostics
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.PRESETS_DEPRECATION_MESSAGE_SUFFIX
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinSourceSetConvention.isRegisteredByKotlinSourceSetConventionAt
|
||||
@@ -346,10 +345,10 @@ object KotlinToolingDiagnostics {
|
||||
)
|
||||
}
|
||||
|
||||
object ExperimentalK2Warning : ToolingDiagnosticFactory(WARNING) {
|
||||
object ExperimentalTryNextWarning : ToolingDiagnosticFactory(WARNING) {
|
||||
operator fun invoke() = build(
|
||||
"""
|
||||
ATTENTION: 'kotlin.experimental.tryK2' is an experimental option enabled in the project for trying out the new Kotlin K2 compiler only.
|
||||
ATTENTION: 'kotlin.experimental.tryNext' is an experimental option enabled in the project for trying out the next Kotlin compiler language version only.
|
||||
Please refrain from using it in production code and provide feedback to the Kotlin team for any issues encountered via https://kotl.in/issue
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
+3
-3
@@ -11,10 +11,10 @@ import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnosticsCollector
|
||||
|
||||
internal object ExperimentalK2UsageChecker : KotlinGradleProjectChecker {
|
||||
internal object ExperimentalTryNextUsageChecker : KotlinGradleProjectChecker {
|
||||
override suspend fun KotlinGradleProjectCheckerContext.runChecks(collector: KotlinToolingDiagnosticsCollector) {
|
||||
if (project.kotlinPropertiesProvider.kotlinExperimentalTryK2.get()) {
|
||||
collector.reportOncePerGradleBuild(project, KotlinToolingDiagnostics.ExperimentalK2Warning())
|
||||
if (project.kotlinPropertiesProvider.kotlinExperimentalTryNext.get()) {
|
||||
collector.reportOncePerGradleBuild(project, KotlinToolingDiagnostics.ExperimentalTryNextWarning())
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.baseModuleName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.moduleNameForCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.native.NativeCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
import org.jetbrains.kotlin.gradle.utils.klibModuleName
|
||||
|
||||
internal object KotlinMultiplatformCommonCompilerOptionsFactory : KotlinCompilationImplFactory.KotlinCompilerOptionsFactory {
|
||||
@@ -19,7 +19,7 @@ internal object KotlinMultiplatformCommonCompilerOptionsFactory : KotlinCompilat
|
||||
val compilerOptions = object : HasCompilerOptions<KotlinMultiplatformCommonCompilerOptions> {
|
||||
override val options: KotlinMultiplatformCommonCompilerOptions = target.project.objects
|
||||
.newInstance(KotlinMultiplatformCommonCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(target.project)
|
||||
.configureExperimentalTryNext(target.project)
|
||||
}
|
||||
|
||||
val kotlinOptions = object : KotlinCommonOptions {
|
||||
@@ -58,7 +58,7 @@ internal object KotlinJsCompilerOptionsFactory : KotlinCompilationImplFactory.Ko
|
||||
val compilerOptions = object : HasCompilerOptions<KotlinJsCompilerOptions> {
|
||||
override val options: KotlinJsCompilerOptions = target.project.objects
|
||||
.newInstance(KotlinJsCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(target.project)
|
||||
.configureExperimentalTryNext(target.project)
|
||||
}
|
||||
|
||||
val kotlinOptions = object : KotlinJsOptions {
|
||||
@@ -75,7 +75,7 @@ internal object KotlinJvmCompilerOptionsFactory : KotlinCompilationImplFactory.K
|
||||
val compilerOptions = object : HasCompilerOptions<KotlinJvmCompilerOptions> {
|
||||
override val options: KotlinJvmCompilerOptions = target.project.objects
|
||||
.newInstance(KotlinJvmCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(target.project)
|
||||
.configureExperimentalTryNext(target.project)
|
||||
}
|
||||
|
||||
val kotlinOptions = object : KotlinJvmOptions {
|
||||
|
||||
+2
-3
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.internal.CustomizeKotlinDependenciesSetupAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnosticsSetupAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.AndroidPluginWithoutAndroidTargetChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.AndroidSourceSetLayoutV1SourceSetsNotFoundChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.CommonMainOrTestWithDependsOnChecker
|
||||
@@ -28,7 +27,7 @@ import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.DeprecatedKotlinN
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.DisabledCinteropCommonizationInHmppProjectChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.DisabledNativeTargetsChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.DuplicateSourceSetChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.ExperimentalK2UsageChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.ExperimentalTryNextUsageChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.IncorrectNativeDependenciesChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.InternalGradlePropertiesUsageChecker
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.JsEnvironmentChecker
|
||||
@@ -158,7 +157,7 @@ internal fun Project.registerKotlinPluginExtensions() {
|
||||
register(project, DisabledNativeTargetsChecker)
|
||||
register(project, JsEnvironmentChecker)
|
||||
register(project, PreHmppDependenciesUsageChecker)
|
||||
register(project, ExperimentalK2UsageChecker)
|
||||
register(project, ExperimentalTryNextUsageChecker)
|
||||
register(project, KotlinSourceSetTreeDependsOnMismatchChecker)
|
||||
register(project, PlatformSourceSetConventionsChecker)
|
||||
register(project, AndroidMainSourceSetConventionsChecker)
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ class KotlinBuildStatHandler {
|
||||
BuildReportType.FILE -> configurationTimeMetrics.put(BooleanMetrics.FILE_BUILD_REPORT, true)
|
||||
BuildReportType.HTTP -> configurationTimeMetrics.put(BooleanMetrics.HTTP_BUILD_REPORT, true)
|
||||
BuildReportType.SINGLE_FILE -> configurationTimeMetrics.put(BooleanMetrics.SINGLE_FILE_BUILD_REPORT, true)
|
||||
BuildReportType.TRY_K2_CONSOLE -> {}//ignore
|
||||
BuildReportType.TRY_NEXT_CONSOLE -> {}//ignore
|
||||
}
|
||||
}
|
||||
val gradle = project.gradle
|
||||
|
||||
+2
-2
@@ -12,10 +12,10 @@ enum class BuildReportType : Serializable {
|
||||
HTTP,
|
||||
BUILD_SCAN,
|
||||
SINGLE_FILE,
|
||||
TRY_K2_CONSOLE,
|
||||
TRY_NEXT_CONSOLE,
|
||||
;
|
||||
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 1L
|
||||
const val serialVersionUID: Long = 2L
|
||||
}
|
||||
}
|
||||
+10
-8
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.gradle.report.data.BuildExecutionData
|
||||
import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord
|
||||
import org.jetbrains.kotlin.gradle.report.data.GradleCompileStatisticsData
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.measureTimeMillisWithResult
|
||||
import org.jetbrains.kotlin.gradle.utils.nextKotlinLanguageVersion
|
||||
import java.io.File
|
||||
import java.net.InetAddress
|
||||
import java.text.SimpleDateFormat
|
||||
@@ -79,8 +80,8 @@ class BuildReportsService {
|
||||
MetricsWriter(singleOutputFile.absoluteFile).process(buildData, log)
|
||||
}
|
||||
|
||||
if (reportingSettings.experimentalTryK2ConsoleOutput) {
|
||||
reportTryK2ToConsole(buildData)
|
||||
if (reportingSettings.experimentalTryNextConsoleOutput) {
|
||||
reportTryNextToConsole(buildData)
|
||||
}
|
||||
|
||||
//It's expected that bad internet connection can cause a significant delay for big project
|
||||
@@ -261,7 +262,7 @@ class BuildReportsService {
|
||||
customValues++
|
||||
}
|
||||
|
||||
private fun reportTryK2ToConsole(
|
||||
private fun reportTryNextToConsole(
|
||||
data: BuildExecutionData
|
||||
) {
|
||||
val tasksData = data.buildOperationRecord
|
||||
@@ -270,21 +271,22 @@ class BuildReportsService {
|
||||
// Filtering by only KGP tasks and by those that actually do compilation
|
||||
it.isFromKotlinPlugin && it.kotlinLanguageVersion != null
|
||||
}
|
||||
log.warn("##### 'kotlin.experimental.tryK2' results #####")
|
||||
log.warn("##### 'kotlin.experimental.tryNext' results #####")
|
||||
if (tasksData.isEmpty()) {
|
||||
log.warn("No Kotlin compilation tasks have been run")
|
||||
log.warn("#####")
|
||||
} else {
|
||||
val tasksCountWithKotlin2 = tasksData.count {
|
||||
it.kotlinLanguageVersion != null && it.kotlinLanguageVersion >= KotlinVersion.KOTLIN_2_0
|
||||
val tasksCountWithKotlinNext = tasksData.count {
|
||||
it.kotlinLanguageVersion != null && it.kotlinLanguageVersion >= KotlinVersion.nextKotlinLanguageVersion
|
||||
}
|
||||
val taskWithK2Percent = (tasksCountWithKotlin2 * 100) / tasksData.count()
|
||||
val taskWithNextPercent = (tasksCountWithKotlinNext * 100) / tasksData.count()
|
||||
val statsData = tasksData.map { it.path to it.kotlinLanguageVersion?.version }
|
||||
statsData.sortedBy { it.first }.forEach { record ->
|
||||
log.warn("${record.first}: ${record.second} language version")
|
||||
}
|
||||
log.warn(
|
||||
"##### $taskWithK2Percent% ($tasksCountWithKotlin2/${tasksData.count()}) tasks have been compiled with Kotlin 2.0 #####"
|
||||
"##### $taskWithNextPercent% ($tasksCountWithKotlinNext/${tasksData.count()}) tasks have been compiled with " +
|
||||
"Kotlin ${KotlinVersion.nextKotlinLanguageVersion.version} #####"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,11 +18,11 @@ data class ReportingSettings(
|
||||
val httpReportSettings: HttpReportSettings? = null,
|
||||
val buildScanReportSettings: BuildScanSettings? = null,
|
||||
val singleOutputFile: File? = null,
|
||||
val experimentalTryK2ConsoleOutput: Boolean = false,
|
||||
val experimentalTryNextConsoleOutput: Boolean = false,
|
||||
val includeCompilerArguments: Boolean = false,
|
||||
) : Serializable {
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 1
|
||||
const val serialVersionUID: Long = 2L
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -8,8 +8,6 @@ package org.jetbrains.kotlin.gradle.report
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.build.report.FileReportSettings
|
||||
import org.jetbrains.kotlin.build.report.HttpReportSettings
|
||||
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
|
||||
import org.jetbrains.kotlin.build.report.metrics.BuildTime
|
||||
import org.jetbrains.kotlin.build.report.metrics.GradleBuildPerformanceMetric
|
||||
import org.jetbrains.kotlin.build.report.metrics.GradleBuildTime
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
@@ -22,13 +20,13 @@ private val availableMetrics = GradleBuildTime.values().map { it.name } + Gradle
|
||||
|
||||
internal fun reportingSettings(project: Project): ReportingSettings {
|
||||
val properties = PropertiesProvider(project)
|
||||
val experimentalTryK2Enabled = properties.kotlinExperimentalTryK2.get()
|
||||
val experimentalTryNextEnabled = properties.kotlinExperimentalTryNext.get()
|
||||
val buildReportOutputTypes = properties.buildReportOutputs
|
||||
.map {
|
||||
BuildReportType.values().firstOrNull { brt -> brt.name == it.trim().toUpperCaseAsciiOnly() }
|
||||
?: throw IllegalStateException("Unknown output type: $it")
|
||||
}
|
||||
.plus(if (experimentalTryK2Enabled) listOf(BuildReportType.TRY_K2_CONSOLE) else emptyList())
|
||||
.plus(if (experimentalTryNextEnabled) listOf(BuildReportType.TRY_NEXT_CONSOLE) else emptyList())
|
||||
.toMutableList() //temporary solution. support old property
|
||||
|
||||
val buildReportMode =
|
||||
@@ -89,7 +87,7 @@ internal fun reportingSettings(project: Project): ReportingSettings {
|
||||
buildReportOutputs = buildReportOutputTypes,
|
||||
singleOutputFile = singleOutputFile ?: oldSingleBuildMetric,
|
||||
includeCompilerArguments = properties.buildReportIncludeCompilerArguments,
|
||||
experimentalTryK2ConsoleOutput = experimentalTryK2Enabled
|
||||
experimentalTryNextConsoleOutput = experimentalTryNextEnabled
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ open class KotlinJsPlugin: Plugin<Project> {
|
||||
kotlinExtension.sourceSets.maybeCreate(TEST_COMPILATION_NAME)
|
||||
|
||||
kotlinExtension.registerTargetObserver { target ->
|
||||
target?.internal?.compilerOptions?.configureExperimentalTryK2(project)
|
||||
target?.internal?.compilerOptions?.configureExperimentalTryNext(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.gradle.plugin.statistics.UsesBuildFusService
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode.DEVELOPMENT
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics
|
||||
import org.jetbrains.kotlin.statistics.metrics.StringMetrics
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||
@@ -36,7 +36,7 @@ abstract class KotlinJsIrLink @Inject constructor(
|
||||
objectFactory: ObjectFactory,
|
||||
workerExecutor: WorkerExecutor,
|
||||
) : Kotlin2JsCompile(
|
||||
objectFactory.newInstance(KotlinJsCompilerOptionsDefault::class.java).configureExperimentalTryK2(project),
|
||||
objectFactory.newInstance(KotlinJsCompilerOptionsDefault::class.java).configureExperimentalTryNext(project),
|
||||
objectFactory,
|
||||
workerExecutor
|
||||
), UsesBuildFusService {
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.reportDiagnostic
|
||||
import org.jetbrains.kotlin.gradle.targets.android.internal.InternalKotlinTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
|
||||
@DeprecatedTargetPresetApi
|
||||
class KotlinJvmWithJavaTargetPreset(
|
||||
@@ -41,7 +41,7 @@ class KotlinJvmWithJavaTargetPreset(
|
||||
object : HasCompilerOptions<KotlinJvmCompilerOptions> {
|
||||
override val options: KotlinJvmCompilerOptions = project.objects
|
||||
.newInstance(KotlinJvmCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
}
|
||||
},
|
||||
{ compilerOptions: KotlinJvmCompilerOptions ->
|
||||
|
||||
+2
-2
@@ -9,11 +9,11 @@ import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptionsDefault
|
||||
import org.jetbrains.kotlin.gradle.plugin.HasCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryNext
|
||||
|
||||
class NativeCompilerOptions(project: Project) : HasCompilerOptions<KotlinNativeCompilerOptions> {
|
||||
|
||||
override val options: KotlinNativeCompilerOptions = project.objects
|
||||
.newInstance(KotlinNativeCompilerOptionsDefault::class.java)
|
||||
.configureExperimentalTryK2(project)
|
||||
.configureExperimentalTryNext(project)
|
||||
}
|
||||
|
||||
+7
-5
@@ -11,18 +11,20 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
|
||||
internal fun <T : KotlinCommonCompilerOptions> T.configureExperimentalTryK2(
|
||||
internal fun <T : KotlinCommonCompilerOptions> T.configureExperimentalTryNext(
|
||||
project: Project,
|
||||
kotlinProperties: PropertiesProvider = project.kotlinPropertiesProvider
|
||||
): T = configureExperimentalTryK2(kotlinProperties)
|
||||
): T = configureExperimentalTryNext(kotlinProperties)
|
||||
|
||||
internal fun <T : KotlinCommonCompilerOptions> T.configureExperimentalTryK2(
|
||||
internal val KotlinVersion.Companion.nextKotlinLanguageVersion get() = KotlinVersion.values().first { it > KotlinVersion.DEFAULT }
|
||||
|
||||
internal fun <T : KotlinCommonCompilerOptions> T.configureExperimentalTryNext(
|
||||
kotlinProperties: PropertiesProvider
|
||||
): T = apply {
|
||||
languageVersion.convention(
|
||||
kotlinProperties.kotlinExperimentalTryK2.map { enabled ->
|
||||
kotlinProperties.kotlinExperimentalTryNext.map { enabled ->
|
||||
@Suppress("TYPE_MISMATCH")
|
||||
if (enabled) KotlinVersion.KOTLIN_2_0 else null
|
||||
if (enabled) KotlinVersion.nextKotlinLanguageVersion else null
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user