diff --git a/buildSrc/src/main/kotlin/CommunityProjectsBuild.kt b/buildSrc/src/main/kotlin/CommunityProjectsBuild.kt index d8a48648fb..155c9e48ac 100644 --- a/buildSrc/src/main/kotlin/CommunityProjectsBuild.kt +++ b/buildSrc/src/main/kotlin/CommunityProjectsBuild.kt @@ -18,6 +18,32 @@ private val LOGGER: Logger = Logger.getLogger("Kotlin settings logger") * are compatible with our libraries (aka "integration testing that substitues lack of unit testing"). */ +/** + * Should be used for running against of non-released Kotlin compiler on a system test level. + * + * @return a Kotlin API version parametrized from command line nor gradle.properties, null otherwise + */ +fun getOverriddenKotlinApiVersion(project: Project): String? { + val apiVersion = project.rootProject.properties["kotlin_api_version"] as? String + if (apiVersion != null) { + LOGGER.info("""Configured Kotlin API version: '$apiVersion' for project $${project.name}""") + } + return apiVersion +} + +/** + * Should be used for running against of non-released Kotlin compiler on a system test level + * + * @return a Kotlin Language version parametrized from command line nor gradle.properties, null otherwise + */ +fun getOverriddenKotlinLanguageVersion(project: Project): String? { + val languageVersion = project.rootProject.properties["kotlin_language_version"] as? String + if (languageVersion != null) { + LOGGER.info("""Configured Kotlin Language version: '$languageVersion' for project ${project.name}""") + } + return languageVersion +} + /** * Should be used for running against of non-released Kotlin compiler on a system test level * Kotlin compiler artifacts are expected to be downloaded from maven central by default. diff --git a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts index 1c3f486a36..9e22b4515c 100644 --- a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts @@ -2,16 +2,19 @@ * Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.kotlin.gradle.tasks.* +import org.jetbrains.kotlin.gradle.dsl.KotlinCompile +import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions configure(subprojects) { + val project = this if (name in sourceless) return@configure apply(plugin = "kotlinx-atomicfu") - val projectName = name - tasks.withType(KotlinCompile::class).all { + tasks.withType>().configureEach { val isMainTaskName = name == "compileKotlin" || name == "compileKotlinJvm" kotlinOptions { - if (isMainTaskName) { + languageVersion = getOverriddenKotlinLanguageVersion(project) + apiVersion = getOverriddenKotlinApiVersion(project) + if (isMainTaskName && versionsAreNotOverridden) { allWarningsAsErrors = true } val newOptions = @@ -23,3 +26,6 @@ configure(subprojects) { } } } + +val KotlinCommonOptions.versionsAreNotOverridden: Boolean + get() = languageVersion == null && apiVersion == null \ No newline at end of file