From c6a39204bb178b4ab66adbbe054d36bd3d6b14d4 Mon Sep 17 00:00:00 2001 From: Bogdan Mukvich Date: Fri, 3 Mar 2023 14:51:40 +0100 Subject: [PATCH] Update user projects config: adapt build script to new TeamCity variables KTI-1227 --- .../src/main/kotlin/CommunityProjectsBuild.kt | 26 +++++++++++++++++++ ...nfigure-compilation-conventions.gradle.kts | 14 +++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) 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