<lambda>null1import java.io.* 2 import java.util.* 3 4 /* 5 * Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 6 */ 7 8 dependencyResolutionManagement { 9 versionCatalogs { 10 create("libs") { 11 from(files("../gradle/libs.versions.toml")) 12 13 overriddenKotlinVersion()?.also { overriddenVersion -> 14 logger.info("Overriding Kotlin version in buildSrc: $overriddenVersion") 15 version("kotlin", overriddenVersion) 16 } 17 } 18 } 19 } 20 overriddenKotlinVersionnull21fun overriddenKotlinVersion(): String? { 22 val kotlinRepoUrl: String? = providers.gradleProperty("kotlin_repo_url").orNull 23 val repoVersion: String? = providers.gradleProperty("kotlin_version").orNull 24 val repoVersionFile: String? 25 26 val bootstrap: String? = providers.gradleProperty("bootstrap").orNull 27 val bootstrapVersion: String? = providers.gradleProperty("kotlin.version.snapshot").orNull 28 val bootstrapVersionFile: String? 29 30 val buildSnapshotTrain: String? = providers.gradleProperty("build_snapshot_train").orNull 31 val trainVersion: String? = providers.gradleProperty("kotlin_snapshot_version").orNull 32 val trainVersionFile: String? 33 34 FileInputStream(file("../gradle.properties")).use { propFile -> 35 val properties = Properties() 36 properties.load(propFile) 37 repoVersionFile = properties["kotlin_version"] as String? 38 bootstrapVersionFile = properties["kotlin.version.snapshot"] as String? 39 trainVersionFile = properties["kotlin_snapshot_version"] as String? 40 } 41 42 if (kotlinRepoUrl?.isNotEmpty() == true) { 43 return repoVersion ?: repoVersionFile ?: throw IllegalArgumentException("\"kotlin_version\" Gradle property should be defined") 44 } else if (bootstrap != null) { 45 return bootstrapVersion ?: bootstrapVersionFile ?: throw IllegalArgumentException("\"kotlin.version.snapshot\" Gradle property should be defined") 46 } 47 if (buildSnapshotTrain?.isNotEmpty() == true) { 48 return trainVersion ?: trainVersionFile ?: throw IllegalArgumentException("\"kotlin_snapshot_version\" should be defined when building with snapshot compiler") 49 } 50 return null 51 }