Skip to content

Commit

Permalink
Update user projects config: adapt build script to new TeamCity varia…
Browse files Browse the repository at this point in the history
…bles

KTI-1227
  • Loading branch information
Badya authored and woainikk committed Jun 23, 2023
1 parent acc6acd commit c6a3920
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
26 changes: 26 additions & 0 deletions buildSrc/src/main/kotlin/CommunityProjectsBuild.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<KotlinCompile<*>>().configureEach {
val isMainTaskName = name == "compileKotlin" || name == "compileKotlinJvm"
kotlinOptions {
if (isMainTaskName) {
languageVersion = getOverriddenKotlinLanguageVersion(project)
apiVersion = getOverriddenKotlinApiVersion(project)
if (isMainTaskName && versionsAreNotOverridden) {
allWarningsAsErrors = true
}
val newOptions =
Expand All @@ -23,3 +26,6 @@ configure(subprojects) {
}
}
}

val KotlinCommonOptions.versionsAreNotOverridden: Boolean
get() = languageVersion == null && apiVersion == null

0 comments on commit c6a3920

Please sign in to comment.