From a14d0d148bcb152a61712e9f78c1d0d30421895e Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Mon, 24 Oct 2022 16:42:51 +0200 Subject: [PATCH] Simplify Kotlin bootstrap application in the project Move all the code to apply Kotlin bootstrap into settings script plugin which does following: - configures based either on the repo root 'local.properties' or on the root project gradle properties or on the repo root 'gradle.properties' current type of bootstrap - automatically adds Kotlin bootstrap repository with exclusive content, so bootstrap dependencies will not be by mistake downloaded from other repository - automatically forces all Kotlin plugins applied in the build to use bootstrap version This script should be applied only in project settings.gradle and then it does all the configuration by itself. --- build.gradle.kts | 27 +- buildSrc/build.gradle.kts | 33 +- buildSrc/settings.gradle | 1 + buildSrc/src/main/kotlin/dependencies.kt | 14 - .../src/Bootstrap.kt | 90 ------ kotlin-native/build-tools/build.gradle.kts | 11 +- .../gradle/kotlinGradlePlugin.gradle | 10 - .../performance/KotlinVsSwift/build.gradle | 3 - kotlin-native/performance/build.gradle | 16 +- .../performance/buildSrc/build.gradle.kts | 22 +- .../performance/buildSrc/settings.gradle.kts | 3 + .../buildSrc/src/main/kotlin/Misc.kt | 2 - kotlin-native/performance/settings.gradle | 10 + .../tools/benchmarksAnalyzer/build.gradle | 15 +- .../buildSrc/build.gradle.kts | 24 +- .../buildSrc/settings.gradle.kts | 3 + .../tools/benchmarksAnalyzer/settings.gradle | 0 .../benchmarksAnalyzer/settings.gradle.kts | 10 + .../tools/performance-server/build.gradle | 18 +- .../buildSrc/build.gradle.kts | 24 +- .../buildSrc/settings.gradle.kts | 3 + .../tools/performance-server/settings.gradle | 10 + .../tools/performance-server/ui/build.gradle | 17 +- .../ui/buildSrc/build.gradle.kts | 24 +- .../ui/buildSrc/settings.gradle.kts | 3 + .../performance-server/ui/settings.gradle | 10 + repo/scripts/Readme.md | 1 + .../kotlin-bootstrap.settings.gradle.kts | 302 ++++++++++++++++++ settings.gradle | 7 +- 29 files changed, 392 insertions(+), 321 deletions(-) delete mode 100644 kotlin-native/tools/benchmarksAnalyzer/settings.gradle create mode 100644 kotlin-native/tools/benchmarksAnalyzer/settings.gradle.kts create mode 100644 repo/scripts/kotlin-bootstrap.settings.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index dae6fb0f202..8c61eaaf35c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,17 +3,6 @@ import org.gradle.plugins.ide.idea.model.IdeaModel import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport buildscript { - val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true - - kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) - - repositories { - bootstrapKotlinRepo?.let(::maven) - - mavenCentral() - gradlePluginPortal() - } - // a workaround for kotlin compiler classpath in kotlin project: sometimes gradle substitutes // kotlin-stdlib external dependency with local project :kotlin-stdlib in kotlinCompilerClasspath configuration. // see also configureCompilerClasspath@ @@ -23,8 +12,6 @@ buildscript { bootstrapCompilerClasspath(kotlin("compiler-embeddable", bootstrapKotlinVersion)) classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") - classpath(kotlin("gradle-plugin", bootstrapKotlinVersion)) - classpath(kotlin("serialization", bootstrapKotlinVersion)) } val versionPropertiesFile = project.rootProject.projectDir.resolve("gradle/versions.properties") @@ -50,6 +37,8 @@ plugins { id("org.gradle.crypto.checksum") version "1.2.0" id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.12.0" apply false signing + id("org.jetbrains.kotlin.jvm") apply false + id("org.jetbrains.kotlin.plugin.serialization") apply false } pill { @@ -502,18 +491,6 @@ allprojects { mirrorRepo?.let(::maven) - internalBootstrapRepo?.let(::maven)?.apply { - content { - includeGroup("org.jetbrains.kotlin") - } - } - - bootstrapKotlinRepo?.let(::maven)?.apply { - content { - includeGroup("org.jetbrains.kotlin") - } - } - maven(intellijRepo) maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index ebda4f407ee..1b4f2827f2b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,28 +1,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile buildscript { - - val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true - - extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion - kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) - - repositories { - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") - - project.bootstrapKotlinRepo?.let { - maven(url = it) - } - } - // workaround for KGP build metrics reports: https://github.com/gradle/gradle/issues/20001 project.extensions.extraProperties["kotlin.build.report.output"] = null - dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") - classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:${project.bootstrapKotlinVersion}") - } - val versionPropertiesFile = project.rootProject.projectDir.parentFile.resolve("gradle/versions.properties") val versionProperties = java.util.Properties() versionPropertiesFile.inputStream().use { propInput -> @@ -43,16 +24,15 @@ logger.info("buildSrc kotlin compiler version: " + org.jetbrains.kotlin.config.K logger.info("buildSrc stdlib version: " + KotlinVersion.CURRENT) apply { - plugin("kotlin") - plugin("kotlin-sam-with-receiver") - plugin("groovy") - from("../gradle/checkCacheability.gradle.kts") } plugins { `kotlin-dsl` `java-gradle-plugin` + `groovy` + id("org.jetbrains.kotlin.jvm") + id("org.jetbrains.kotlin.plugin.sam.with.receiver") } gradlePlugin { @@ -159,16 +139,17 @@ java { dependencies { implementation(kotlin("stdlib", embeddedKotlinVersion)) - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") implementation("com.gradle.publish:plugin-publish-plugin:1.0.0") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.7.0") implementation("com.jakewharton.dex:dex-member-list:4.1.1") - implementation("gradle.plugin.com.github.johnrengelman:shadow:${rootProject.extra["versions.shadow"]}") + implementation("gradle.plugin.com.github.johnrengelman:shadow:${rootProject.extra["versions.shadow"]}") { + // https://github.com/johnrengelman/shadow/issues/807 + exclude("org.ow2.asm") + } implementation("net.sf.proguard:proguard-gradle:6.2.2") - implementation("org.jetbrains.intellij.deps:asm-all:8.0.1") implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.0.1") diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle index 43316f63491..a98e09a6af4 100644 --- a/buildSrc/settings.gradle +++ b/buildSrc/settings.gradle @@ -1,5 +1,6 @@ pluginManagement { apply from: '../repo/scripts/cache-redirector.settings.gradle.kts' + apply from: '../repo/scripts/kotlin-bootstrap.settings.gradle.kts' repositories { maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } mavenCentral() diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt index aed5a08f849..512f05f05be 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/src/main/kotlin/dependencies.kt @@ -26,20 +26,6 @@ val Project.intellijRepo else -> "https://www.jetbrains.com/intellij-repository/releases" } -val Project.internalBootstrapRepo: String? - get() = - when { - bootstrapKotlinRepo?.startsWith("https://buildserver.labs.intellij.net") == true - || bootstrapKotlinRepo?.startsWith("https://teamcity.jetbrains.com") == true -> - bootstrapKotlinRepo!!.replace("artifacts/content/maven", "artifacts/content/internal/repo") - - project.kotlinBuildProperties.isJpsBuildEnabled -> - "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Aggregate)," + - "number:$bootstrapKotlinVersion,branch:default:any/artifacts/content/internal/repo/" - - else -> null - } - fun Project.commonDependency(coordinates: String): String { val parts = coordinates.split(':') return when (parts.size) { diff --git a/dependencies/kotlin-build-gradle-plugin/src/Bootstrap.kt b/dependencies/kotlin-build-gradle-plugin/src/Bootstrap.kt index c2ad1006f35..29dbdd0e63b 100644 --- a/dependencies/kotlin-build-gradle-plugin/src/Bootstrap.kt +++ b/dependencies/kotlin-build-gradle-plugin/src/Bootstrap.kt @@ -16,93 +16,3 @@ var Project.bootstrapKotlinRepo: String? private set(value) { extensions.extraProperties.set("bootstrapKotlinRepo", value) } - -fun Project.kotlinBootstrapFrom(defaultSource: BootstrapOption) { - val teamCityBootstrapVersion = kotlinBuildProperties.teamCityBootstrapVersion - val customBootstrapVersion = kotlinBuildProperties.customBootstrapVersion - val bootstrapSource = when { - kotlinBuildProperties.localBootstrap -> BootstrapOption.Local( - kotlinBuildProperties.localBootstrapVersion, - kotlinBuildProperties.localBootstrapPath - ) - teamCityBootstrapVersion != null -> BootstrapOption.TeamCity( - teamCityBootstrapVersion, - kotlinBuildProperties.teamCityBootstrapBuildNumber, - projectExtId = kotlinBuildProperties.teamCityBootstrapProject, - teamcityUrl = kotlinBuildProperties.teamCityBootstrapUrl, - onlySuccessBootstrap = false - ) - customBootstrapVersion != null -> BootstrapOption.Custom( - kotlinVersion = customBootstrapVersion, - repo = kotlinBuildProperties.customBootstrapRepo - ) - else -> defaultSource - } - - bootstrapSource.applyToProject(this) - logger.lifecycle("Using kotlin bootstrap version $bootstrapKotlinVersion from repo $bootstrapKotlinRepo") -} - -sealed class BootstrapOption { - abstract fun applyToProject(project: Project) - - /** Manual repository and version specification. - * - * If [repo] is not specified the default buildscript and project repositories are used - */ - open class Custom(val kotlinVersion: String, val repo: String?, val cacheRedirector: Boolean = false) : BootstrapOption() { - override fun applyToProject(project: Project) { - project.bootstrapKotlinVersion = kotlinVersion - project.bootstrapKotlinRepo = if (cacheRedirector) - repo?.let { URI(it) }?.let { "https://cache-redirector.jetbrains.com/${it.host}/${it.path}" } - else - repo - } - } - - /** Get bootstrap from kotlin bootstrap space repo, where bootstraps are published */ - class SpaceBootstrap(kotlinVersion: String, cacheRedirector: Boolean = false) : - Custom(kotlinVersion, "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap", cacheRedirector) - - /** Get bootstrap from teamcity maven artifacts of the specified build configuration - * - * [kotlinVersion] the version of maven artifacts - * [buildNumber] build number of a teamcity build, by default the same as [kotlinVersion], - * [projectExtId] extId of a teamcity build configuration, by default "Kotlin_dev_Compiler", - * [onlySuccessBootstrap] allow artifacts only from success builds of the default branch tagged with 'bootstrap' tag - */ - class TeamCity( - val kotlinVersion: String, - val buildNumber: String? = null, - val projectExtId: String? = null, - val onlySuccessBootstrap: Boolean = true, - val teamcityUrl: String? = null - ) : BootstrapOption() { - override fun applyToProject(project: Project) { - val query = if (onlySuccessBootstrap) "status:SUCCESS,tag:bootstrap,pinned:true" else "branch:default:any" - project.bootstrapKotlinRepo = - "${teamcityUrl ?: "https://buildserver.labs.intellij.net"}/guestAuth/app/rest/builds/buildType:(id:${projectExtId - ?: "Kotlin_KotlinDev_Compiler"}),number:${buildNumber ?: kotlinVersion},$query/artifacts/content/maven/" - project.bootstrapKotlinVersion = kotlinVersion - } - } - - /** - * Use previously published local artifacts from the build/repo maven repository - * - * [kotlinVersion] version of artifacts, by default the snapshot version of project is used - * [localPath] the path to local repository, if specified it is resolved with respect or project dir - */ - class Local(val kotlinVersion: String? = null, val localPath: String? = null) : BootstrapOption() { - override fun applyToProject(project: Project) { - val rootProjectDir = project.kotlinBuildProperties.rootProjectDir - val repoPath = if (localPath != null) - rootProjectDir.resolve(localPath).canonicalFile - else - rootProjectDir.resolve("build").resolve("repo") - - project.bootstrapKotlinRepo = repoPath.toURI().toString() - project.bootstrapKotlinVersion = kotlinVersion ?: project.property("defaultSnapshotVersion") as String - } - } -} diff --git a/kotlin-native/build-tools/build.gradle.kts b/kotlin-native/build-tools/build.gradle.kts index 765b13765d2..44cd9031485 100644 --- a/kotlin-native/build-tools/build.gradle.kts +++ b/kotlin-native/build-tools/build.gradle.kts @@ -12,26 +12,17 @@ plugins { groovy `kotlin-dsl` id("gradle-plugin-dependency-configuration") + id("org.jetbrains.kotlin.plugin.sam.with.receiver") } buildscript { val rootBuildDirectory by extra(project.file("../..")) - repositories { - project.bootstrapKotlinRepo?.let { - maven(url = it) - } - } - apply(from = rootBuildDirectory.resolve("kotlin-native/gradle/loadRootProperties.gradle")) dependencies { classpath(commonDependency("com.google.code.gson:gson")) - classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:${project.bootstrapKotlinVersion}") } } -apply { - plugin("kotlin-sam-with-receiver") -} val rootProperties = Properties().apply { project(":kotlin-native").projectDir.resolve("gradle.properties").reader().use(::load) diff --git a/kotlin-native/gradle/kotlinGradlePlugin.gradle b/kotlin-native/gradle/kotlinGradlePlugin.gradle index 2ec891405a3..5a1992a65d7 100644 --- a/kotlin-native/gradle/kotlinGradlePlugin.gradle +++ b/kotlin-native/gradle/kotlinGradlePlugin.gradle @@ -1,11 +1,5 @@ import org.jetbrains.kotlin.UtilsKt -project.buildscript.repositories { - maven { - url BootstrapKt.getBootstrapKotlinRepo(project) - } - mavenCentral() -} def kotlinRoot = ext.properties.containsKey("rootBuildDirectory") ? file("${ext.rootBuildDirectory}/..") : rootProject.projectDir File versionPropertiesFile = new File(kotlinRoot, "gradle/versions.properties") def versionProperties = new Properties() @@ -22,10 +16,6 @@ project.buildscript.configurations.all { } } -project.buildscript.dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}" -} - configurations { kotlinCompilerClasspath } diff --git a/kotlin-native/performance/KotlinVsSwift/build.gradle b/kotlin-native/performance/KotlinVsSwift/build.gradle index 880782e4bd0..eb6ea978dce 100644 --- a/kotlin-native/performance/KotlinVsSwift/build.gradle +++ b/kotlin-native/performance/KotlinVsSwift/build.gradle @@ -1,8 +1,5 @@ buildscript { apply from: "$rootProject.projectDir/../gradle/kotlinGradlePlugin.gradle" - repositories { - mavenCentral() - } } def rootBuildDirectory = rootProject.projectDir diff --git a/kotlin-native/performance/build.gradle b/kotlin-native/performance/build.gradle index 246bae2bae9..d307435e256 100644 --- a/kotlin-native/performance/build.gradle +++ b/kotlin-native/performance/build.gradle @@ -23,16 +23,16 @@ buildscript { apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle" apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle" - repositories { - maven{ url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } - mavenCentral() - } dependencies { classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") } } +plugins { + id("org.jetbrains.kotlin.multiplatform") apply false +} + def globalProperties = new java.util.Properties() ext.kotlin_root = project.file("../..").absolutePath project.logger.info("kotlin_root: $kotlin_root") @@ -81,16 +81,8 @@ subprojects { proj -> if (deploySnapshotStr != "default.snapshot") deploySnapshotStr else defaultSnapshotVersion } ?: proj.ext["buildNumber"] - proj.buildscript.repositories { - maven { - url proj.ext["bootstrapKotlinRepo"] - } - } proj.repositories { mavenCentral() - maven { - url proj.ext["bootstrapKotlinRepo"] - } } } diff --git a/kotlin-native/performance/buildSrc/build.gradle.kts b/kotlin-native/performance/buildSrc/build.gradle.kts index d2130cb424f..fd638f943e1 100644 --- a/kotlin-native/performance/buildSrc/build.gradle.kts +++ b/kotlin-native/performance/buildSrc/build.gradle.kts @@ -14,39 +14,23 @@ buildscript { val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion - kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) - - repositories { - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") - mavenCentral() - project.bootstrapKotlinRepo?.let { - maven(url = it) - } - } dependencies { classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") } } -apply{ - plugin("kotlin") - plugin("kotlin-sam-with-receiver") -} plugins { `kotlin-dsl` - //kotlin("multiplatform") version "${project.bootstrapKotlinVersion}" + id("org.jetbrains.kotlin.jvm") + id("org.jetbrains.kotlin.plugin.sam.with.receiver") + //kotlin("multiplatform") } -val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true repositories { maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") mavenCentral() gradlePluginPortal() - extra["bootstrapKotlinRepo"]?.let { - maven(url = it) - } } tasks.validatePlugins.configure { diff --git a/kotlin-native/performance/buildSrc/settings.gradle.kts b/kotlin-native/performance/buildSrc/settings.gradle.kts index af5c8428bb5..70d6212732e 100644 --- a/kotlin-native/performance/buildSrc/settings.gradle.kts +++ b/kotlin-native/performance/buildSrc/settings.gradle.kts @@ -1,5 +1,8 @@ import java.io.File pluginManagement { + apply(from = "../../../repo/scripts/cache-redirector.settings.gradle.kts") + apply(from = "../../../repo/scripts/kotlin-bootstrap.settings.gradle.kts") + repositories { maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") mavenCentral() diff --git a/kotlin-native/performance/buildSrc/src/main/kotlin/Misc.kt b/kotlin-native/performance/buildSrc/src/main/kotlin/Misc.kt index 936da671588..0028927cbab 100644 --- a/kotlin-native/performance/buildSrc/src/main/kotlin/Misc.kt +++ b/kotlin-native/performance/buildSrc/src/main/kotlin/Misc.kt @@ -6,8 +6,6 @@ import org.gradle.api.Project fun Project.kotlinInit(cacheRedirectorEnabled: Boolean) { extensions.extraProperties["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion - kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) - extensions.extraProperties["kotlinVersion"] = findProperty("kotlinVersion") extensions.extraProperties["konanVersion"] = findProperty("konanVersion") } diff --git a/kotlin-native/performance/settings.gradle b/kotlin-native/performance/settings.gradle index dfd38716cf4..c6c40d44ba5 100644 --- a/kotlin-native/performance/settings.gradle +++ b/kotlin-native/performance/settings.gradle @@ -2,6 +2,16 @@ * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE file. */ +pluginManagement { + apply from: '../../repo/scripts/cache-redirector.settings.gradle.kts' + apply from: '../../repo/scripts/kotlin-bootstrap.settings.gradle.kts' + + repositories { + maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } + mavenCentral() + gradlePluginPortal() + } +} include ':ring' include ':cinterop' diff --git a/kotlin-native/tools/benchmarksAnalyzer/build.gradle b/kotlin-native/tools/benchmarksAnalyzer/build.gradle index 588174481c3..0cba2a4da52 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/build.gradle +++ b/kotlin-native/tools/benchmarksAnalyzer/build.gradle @@ -21,22 +21,13 @@ buildscript { apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle" apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle" - - repositories { - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - } } -apply plugin: 'kotlin-multiplatform' +plugins { + id("org.jetbrains.kotlin.multiplatform") +} repositories { - maven { - url project.bootstrapKotlinRepo - } mavenCentral() } diff --git a/kotlin-native/tools/benchmarksAnalyzer/buildSrc/build.gradle.kts b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/build.gradle.kts index c54dc956c6f..4032993c014 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/buildSrc/build.gradle.kts +++ b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/build.gradle.kts @@ -11,44 +11,26 @@ buildscript { extra[key] = value } - val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false - extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion - kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) extra["bootstrapKotlinRepo"] = project.bootstrapKotlinRepo extra["bootstrapKotlinVersion"] = project.bootstrapKotlinVersion - repositories { - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") - mavenCentral() - project.bootstrapKotlinRepo?.let { - maven(url = it) - } - } - dependencies { classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") } } -apply{ - plugin("kotlin") - plugin("kotlin-sam-with-receiver") -} plugins { `kotlin-dsl` - //kotlin("multiplatform") version "${project.bootstrapKotlinVersion}" + id("org.jetbrains.kotlin.jvm") + id("org.jetbrains.kotlin.plugin.sam.with.receiver") + //kotlin("multiplatform") } -val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true repositories { maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") mavenCentral() gradlePluginPortal() - extra["bootstrapKotlinRepo"]?.let { - maven(url = it) - } } tasks.validatePlugins.configure { diff --git a/kotlin-native/tools/benchmarksAnalyzer/buildSrc/settings.gradle.kts b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/settings.gradle.kts index 6762ff93f7e..554675d9f4e 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/buildSrc/settings.gradle.kts +++ b/kotlin-native/tools/benchmarksAnalyzer/buildSrc/settings.gradle.kts @@ -1,4 +1,7 @@ pluginManagement { + apply(from = "../../../../repo/scripts/cache-redirector.settings.gradle.kts") + apply(from = "../../../../repo/scripts/kotlin-bootstrap.settings.gradle.kts") + repositories { maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") mavenCentral() diff --git a/kotlin-native/tools/benchmarksAnalyzer/settings.gradle b/kotlin-native/tools/benchmarksAnalyzer/settings.gradle deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/kotlin-native/tools/benchmarksAnalyzer/settings.gradle.kts b/kotlin-native/tools/benchmarksAnalyzer/settings.gradle.kts new file mode 100644 index 00000000000..6e9eab04cd4 --- /dev/null +++ b/kotlin-native/tools/benchmarksAnalyzer/settings.gradle.kts @@ -0,0 +1,10 @@ +pluginManagement { + apply(from = "../../../repo/scripts/cache-redirector.settings.gradle.kts") + apply(from = "../../../repo/scripts/kotlin-bootstrap.settings.gradle.kts") + + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + mavenCentral() + gradlePluginPortal() + } +} diff --git a/kotlin-native/tools/performance-server/build.gradle b/kotlin-native/tools/performance-server/build.gradle index 81c5c802eb7..e3123a67658 100644 --- a/kotlin-native/tools/performance-server/build.gradle +++ b/kotlin-native/tools/performance-server/build.gradle @@ -20,26 +20,14 @@ buildscript { apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle" apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle" - - repositories { - mavenCentral() - maven { - url project.bootstrapKotlinRepo - } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - } } -apply plugin: 'kotlin-multiplatform' +plugins { + id("org.jetbrains.kotlin.multiplatform") +} repositories { mavenCentral() - maven { - url project.bootstrapKotlinRepo - } } kotlin { diff --git a/kotlin-native/tools/performance-server/buildSrc/build.gradle.kts b/kotlin-native/tools/performance-server/buildSrc/build.gradle.kts index f3dc136e14f..ab0de06e228 100644 --- a/kotlin-native/tools/performance-server/buildSrc/build.gradle.kts +++ b/kotlin-native/tools/performance-server/buildSrc/build.gradle.kts @@ -11,43 +11,26 @@ buildscript { extra[key] = value } - val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion - kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) extra["bootstrapKotlinRepo"] = project.bootstrapKotlinRepo extra["bootstrapKotlinVersion"] = project.bootstrapKotlinVersion - repositories { - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") - project.bootstrapKotlinRepo?.let { - maven(url = it) - } - mavenCentral() - } - dependencies { classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") } } -apply{ - plugin("kotlin") - plugin("kotlin-sam-with-receiver") -} plugins { `kotlin-dsl` - //kotlin("multiplatform") version "${project.bootstrapKotlinVersion}" + id("org.jetbrains.kotlin.jvm") + id("org.jetbrains.kotlin.plugin.sam.with.receiver") + //kotlin("multiplatform") } -val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true repositories { maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") gradlePluginPortal() - extra["bootstrapKotlinRepo"]?.let { - maven(url = it) - } mavenCentral() } @@ -55,7 +38,6 @@ tasks.validatePlugins.configure { enabled = false } - sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) { kotlin.filter.exclude("**/FileCheckTest.kt") kotlin.filter.exclude("**/bitcode/**") diff --git a/kotlin-native/tools/performance-server/buildSrc/settings.gradle.kts b/kotlin-native/tools/performance-server/buildSrc/settings.gradle.kts index 6762ff93f7e..554675d9f4e 100644 --- a/kotlin-native/tools/performance-server/buildSrc/settings.gradle.kts +++ b/kotlin-native/tools/performance-server/buildSrc/settings.gradle.kts @@ -1,4 +1,7 @@ pluginManagement { + apply(from = "../../../../repo/scripts/cache-redirector.settings.gradle.kts") + apply(from = "../../../../repo/scripts/kotlin-bootstrap.settings.gradle.kts") + repositories { maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") mavenCentral() diff --git a/kotlin-native/tools/performance-server/settings.gradle b/kotlin-native/tools/performance-server/settings.gradle index e69de29bb2d..a22f8336d3f 100644 --- a/kotlin-native/tools/performance-server/settings.gradle +++ b/kotlin-native/tools/performance-server/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + apply from: '../../../repo/scripts/cache-redirector.settings.gradle.kts' + apply from: '../../../repo/scripts/kotlin-bootstrap.settings.gradle.kts' + + repositories { + maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } + mavenCentral() + gradlePluginPortal() + } +} \ No newline at end of file diff --git a/kotlin-native/tools/performance-server/ui/build.gradle b/kotlin-native/tools/performance-server/ui/build.gradle index 7c21e0f1f09..18c5be2e4ed 100644 --- a/kotlin-native/tools/performance-server/ui/build.gradle +++ b/kotlin-native/tools/performance-server/ui/build.gradle @@ -22,27 +22,16 @@ buildscript { apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle" apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle" +} - repositories { - mavenCentral() - maven { - url project.bootstrapKotlinRepo - } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - } +plugins { + id("org.jetbrains.kotlin.multiplatform") } repositories { mavenCentral() - maven { - url project.bootstrapKotlinRepo - } } -apply plugin: 'kotlin-multiplatform' kotlin { js(IR) { diff --git a/kotlin-native/tools/performance-server/ui/buildSrc/build.gradle.kts b/kotlin-native/tools/performance-server/ui/buildSrc/build.gradle.kts index 217bfb0bf50..1a67a126408 100644 --- a/kotlin-native/tools/performance-server/ui/buildSrc/build.gradle.kts +++ b/kotlin-native/tools/performance-server/ui/buildSrc/build.gradle.kts @@ -11,49 +11,31 @@ buildscript { extra[key] = value } - val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false - extra["defaultSnapshotVersion"] = kotlinBuildProperties.defaultSnapshotVersion - kotlinBootstrapFrom(BootstrapOption.SpaceBootstrap(kotlinBuildProperties.kotlinBootstrapVersion!!, cacheRedirectorEnabled)) extra["bootstrapKotlinRepo"] = project.bootstrapKotlinRepo extra["bootstrapKotlinVersion"] = project.bootstrapKotlinVersion - repositories { - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") - project.bootstrapKotlinRepo?.let { - maven(url = it) - } - } - dependencies { classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") } } -apply{ - plugin("kotlin") - plugin("kotlin-sam-with-receiver") -} plugins { `kotlin-dsl` - //kotlin("multiplatform") version "${project.bootstrapKotlinVersion}" + id("org.jetbrains.kotlin.jvm") + id("org.jetbrains.kotlin.plugin.sam.with.receiver") + //kotlin("multiplatform") } -val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true repositories { maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") gradlePluginPortal() - extra["bootstrapKotlinRepo"]?.let { - maven(url = it) - } } tasks.validatePlugins.configure { enabled = false } - sourceSets["main"].withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) { kotlin.filter.exclude("**/FileCheckTest.kt") kotlin.filter.exclude("**/bitcode/**") diff --git a/kotlin-native/tools/performance-server/ui/buildSrc/settings.gradle.kts b/kotlin-native/tools/performance-server/ui/buildSrc/settings.gradle.kts index 8266b22c175..fc7d4fc151f 100644 --- a/kotlin-native/tools/performance-server/ui/buildSrc/settings.gradle.kts +++ b/kotlin-native/tools/performance-server/ui/buildSrc/settings.gradle.kts @@ -1,4 +1,7 @@ pluginManagement { + apply(from = "../../../../../repo/scripts/cache-redirector.settings.gradle.kts") + apply(from = "../../../../../repo/scripts/kotlin-bootstrap.settings.gradle.kts") + repositories { maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") diff --git a/kotlin-native/tools/performance-server/ui/settings.gradle b/kotlin-native/tools/performance-server/ui/settings.gradle index e69de29bb2d..7844c61c969 100644 --- a/kotlin-native/tools/performance-server/ui/settings.gradle +++ b/kotlin-native/tools/performance-server/ui/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + apply from: '../../../../repo/scripts/cache-redirector.settings.gradle.kts' + apply from: '../../../../repo/scripts/kotlin-bootstrap.settings.gradle.kts' + + repositories { + maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } + mavenCentral() + gradlePluginPortal() + } +} diff --git a/repo/scripts/Readme.md b/repo/scripts/Readme.md index 3e22aeb8561..d2993867767 100644 --- a/repo/scripts/Readme.md +++ b/repo/scripts/Readme.md @@ -3,3 +3,4 @@ This directory contains the scripts that should be applied before even settings evaluation and cannot be convention plugins: - [script](cache-redirector.settings.gradle.kts) to redirect all repositories to cache redirector service +- [script](kotlin-bootstrap.settings.gradle.kts) to apply Kotlin bootstrap settings diff --git a/repo/scripts/kotlin-bootstrap.settings.gradle.kts b/repo/scripts/kotlin-bootstrap.settings.gradle.kts new file mode 100644 index 00000000000..5b6e8b33582 --- /dev/null +++ b/repo/scripts/kotlin-bootstrap.settings.gradle.kts @@ -0,0 +1,302 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +// Apply this settings script in the project settings.gradle following way: +// pluginManagement { +// apply from: 'kotlin-bootstrap.settings.gradle.kts' +// } + +import java.util.Properties +import org.gradle.api.internal.GradleInternal + +object Config { + const val LOCAL_BOOTSTRAP = "bootstrap.local" + const val LOCAL_BOOTSTRAP_VERSION = "bootstrap.local.version" + const val LOCAL_BOOTSTRAP_PATH = "bootstrap.local.path" + + const val TEAMCITY_BOOTSTRAP_VERSION = "bootstrap.teamcity.kotlin.version" + const val TEAMCITY_BOOTSTRAP_BUILD_NUMBER = "bootstrap.teamcity.build.number" + const val TEAMCITY_BOOTSTRAP_PROJECT = "bootstrap.teamcity.project" + const val TEAMCITY_BOOTSTRAP_URL = "bootstrap.teamcity.url" + + const val CUSTOM_BOOTSTRAP_VERSION = "bootstrap.kotlin.version" + const val CUSTOM_BOOTSTRAP_REPO = "bootstrap.kotlin.repo" + + const val DEFAULT_SNAPSHOT_VERSION = "defaultSnapshotVersion" + const val DEFAULT_BOOTSTRAP_VERSION = "bootstrap.kotlin.default.version" + + const val PROJECT_KOTLIN_VERSION = "bootstrapKotlinVersion" + const val PROJECT_KOTLIN_REPO = "bootstrapKotlinRepo" + + const val IS_JPS_BUILD_ENABLED = "jpsBuild" +} + +abstract class PropertiesValueSource : ValueSource { + interface Parameters : ValueSourceParameters { + val fileName: Property + val rootDir: Property + } + + override fun obtain(): Properties? { + val localPropertiesFile = parameters.rootDir.get().resolve(parameters.fileName.get()) + return if (localPropertiesFile.exists()) { + localPropertiesFile.bufferedReader().use { + Properties().apply { load(it) } + } + } else { + null + } + } +} + +fun getRootSettings( + settings: Settings, + gradle: Gradle +): Settings { + // Gradle interface neither exposes flag if it is a root of composite-build hierarchy + // nor gives access to Settings object. Fortunately it is availaibe inside GradleInternal internal api + // used by build scan plugin. + val gradleInternal = (gradle as GradleInternal) + return if (gradleInternal.isRootBuild()) { + settings + } else { + val gradleParent = gradle.parent ?: error("Could not get includedBuild parent build for ${settings.rootDir}!") + getRootSettings(gradle.parent!!.settings, gradle.parent!!) + } +} + +val rootSettings = getRootSettings(settings, settings.gradle) + +// Workaround for the case when included build could be run directly via --project-dir option. +// In this case `rootSettings.rootDir` will point to --project-dir location rather then Kotlin repo real root. +// So in such case script falls back to manual mapping +val kotlinRootDir: File = when (rootSettings.rootProject.name) { + "buildSrc" -> { + val parentDir = rootSettings.rootDir.parentFile + when (parentDir.name) { + "benchmarksAnalyzer", "performance-server" -> parentDir.parentFile.parentFile.parentFile + "performance" -> parentDir.parentFile.parentFile + "ui" -> parentDir.parentFile.parentFile.parentFile.parentFile + else -> parentDir + } + } + "benchmarksAnalyzer", "performance-server" -> rootSettings.rootDir.parentFile.parentFile.parentFile + "performance" -> rootSettings.rootDir.parentFile.parentFile + "ui" -> rootSettings.rootDir.parentFile.parentFile.parentFile.parentFile + else -> rootSettings.rootDir +} + +private val localProperties = providers.of(PropertiesValueSource::class.java) { + parameters { + fileName.set("local.properties") + rootDir.set(kotlinRootDir) + } +}.forUseAtConfigurationTime() + +private val rootGradleProperties = providers.of(PropertiesValueSource::class.java) { + parameters { + fileName.set("gradle.properties") + rootDir.set(kotlinRootDir) + } +}.forUseAtConfigurationTime() + +fun loadLocalOrGradleProperty( + propertyName: String +): Provider { + // Workaround for https://github.com/gradle/gradle/issues/19114 + // as in the includedBuild GradleProperties are empty on configuration cache reuse + return if ((gradle as GradleInternal).isRootBuild()) { + localProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime() + .orElse(providers.gradleProperty(propertyName).forUseAtConfigurationTime()) + .orElse(rootGradleProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime()) + } else { + localProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime() + .orElse(rootSettings.providers.gradleProperty(propertyName).forUseAtConfigurationTime()) + .orElse(rootGradleProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime()) + } +} + +fun Project.logBootstrapApplied(message: String) { + if (this == rootProject) logger.lifecycle(message) else logger.info(message) +} + +fun String?.propValueToBoolean(default: Boolean = false): Boolean { + return when { + this == null -> default + isEmpty() -> true // has property without value means 'true' + else -> trim().toBoolean() + } +} + +fun Provider.mapToBoolean(): Provider = map { it?.propValueToBoolean() } + +fun RepositoryHandler.addBootstrapRepo( + bootstrapRepo: String, + bootstrapVersion: String, + additionalBootstrapRepos: List = emptyList() +) { + exclusiveContent { + forRepositories( + *(listOf(bootstrapRepo) + additionalBootstrapRepos) + .map { + maven { url = uri(it) } + } + .toTypedArray() + ) + filter { + // kotlin-build-gradle-plugin and non bootstrap-versions + // should be excluded from strict content filtering + includeVersionByRegex( + "org\\.jetbrains\\.kotlin", + "^(?!kotlin-build-gradle-plugin).*$", + bootstrapVersion.toRegex().pattern + ) + + // Kotlin Gradle plugins that have slightly separate maven coordinates + includeVersionByRegex( + "org\\.jetbrains\\.kotlin\\..*$", + "org\\.jetbrains\\.kotlin\\..*\\.gradle\\.plugin$", + bootstrapVersion.toRegex().pattern + ) + } + } +} + +@OptIn(kotlin.ExperimentalStdlibApi::class) +fun getAdditionalBootstrapRepos( + bootstrapRepo: String, + bootstrapKotlinVersion: String, + isJpsBuildEnabled: Boolean +): List { + return buildList { + if (bootstrapRepo.startsWith("https://buildserver.labs.intellij.net") + || bootstrapRepo.startsWith("https://teamcity.jetbrains.com")) { + add(bootstrapRepo.replace("artifacts/content/maven", "artifacts/content/internal/repo")) + } + + if (isJpsBuildEnabled) { + add( + "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Aggregate)," + + "number:$bootstrapKotlinVersion,branch:default:any/artifacts/content/internal/repo/" + ) + } + } +} + +fun Settings.applyBootstrapConfiguration( + bootstrapVersion: String, + bootstrapRepo: String, + isJpsBuildEnabled: Boolean, + logMessage: String +) { + settings.pluginManagement.repositories.addBootstrapRepo(bootstrapRepo, bootstrapVersion) + settings.pluginManagement.resolutionStrategy.eachPlugin { + if (requested.id.id.startsWith("org.jetbrains.kotlin.")) { + useVersion(bootstrapVersion) + } + } + + val additionalRepos = getAdditionalBootstrapRepos(bootstrapRepo, bootstrapVersion, isJpsBuildEnabled) + gradle.beforeProject { + bootstrapKotlinVersion = bootstrapVersion + bootstrapKotlinRepo = bootstrapRepo + + repositories.addBootstrapRepo(bootstrapRepo, bootstrapVersion, additionalRepos) + + logBootstrapApplied(logMessage) + } +} + +val isLocalBootstrapEnabled: Provider = loadLocalOrGradleProperty(Config.LOCAL_BOOTSTRAP) + .mapToBoolean().orElse(false).forUseAtConfigurationTime() + +val localBootstrapVersion: Provider = loadLocalOrGradleProperty(Config.LOCAL_BOOTSTRAP_VERSION) + .orElse(loadLocalOrGradleProperty(Config.DEFAULT_SNAPSHOT_VERSION)) + +val localBootstrapPath: Provider = loadLocalOrGradleProperty(Config.LOCAL_BOOTSTRAP_PATH) +val teamCityBootstrapVersion = loadLocalOrGradleProperty(Config.TEAMCITY_BOOTSTRAP_VERSION) +val teamCityBootstrapBuildNumber = loadLocalOrGradleProperty(Config.TEAMCITY_BOOTSTRAP_BUILD_NUMBER) +val teamCityBootstrapProject = loadLocalOrGradleProperty(Config.TEAMCITY_BOOTSTRAP_PROJECT) +val teamCityBootstrapUrl = loadLocalOrGradleProperty(Config.TEAMCITY_BOOTSTRAP_URL) +val customBootstrapVersion = loadLocalOrGradleProperty(Config.CUSTOM_BOOTSTRAP_VERSION) +val customBootstrapRepo = loadLocalOrGradleProperty(Config.CUSTOM_BOOTSTRAP_REPO) +val defaultBootstrapVersion = loadLocalOrGradleProperty(Config.DEFAULT_BOOTSTRAP_VERSION) +val isJpsBuildEnabled = loadLocalOrGradleProperty(Config.IS_JPS_BUILD_ENABLED) + .mapToBoolean().orElse(false).forUseAtConfigurationTime() + +var Project.bootstrapKotlinVersion: String + get() = property(Config.PROJECT_KOTLIN_VERSION) as String + set(value) { + extensions.extraProperties.set(Config.PROJECT_KOTLIN_VERSION, value) + } + +var Project.bootstrapKotlinRepo: String? + get() = property(Config.PROJECT_KOTLIN_REPO) as String? + set(value) { + extensions.extraProperties.set(Config.PROJECT_KOTLIN_REPO, value) + } + +// Get bootstrap kotlin version and repository url +// and set it using pluginManagement and dependencyManangement +when { + isLocalBootstrapEnabled.get() -> { + val bootstrapVersion = localBootstrapVersion.get() + + val localPath = localBootstrapPath.orNull + val rootDirectory = rootSettings.rootDir + val repoPath = if (localPath != null) { + rootDirectory.resolve(localPath).canonicalFile + } else { + rootDirectory.resolve("build").resolve("repo") + } + val bootstrapRepo = repoPath.toURI().toString() + + applyBootstrapConfiguration( + bootstrapVersion, + bootstrapRepo, + isJpsBuildEnabled.get(), + "Using Kotlin local bootstrap version $bootstrapVersion from $bootstrapRepo" + ) + } + teamCityBootstrapVersion.orNull != null -> { + val bootstrapVersion = teamCityBootstrapVersion.get() + + val query = "branch:default:any" + val baseRepoUrl = teamCityBootstrapUrl.orNull ?: "https://buildserver.labs.intellij.net" + val teamCityProjectId = teamCityBootstrapProject.orNull ?: "Kotlin_KotlinDev_Compiler" + val teamCityBuildNumber = teamCityBootstrapBuildNumber.orNull ?: bootstrapVersion + + val bootstrapRepo = "$baseRepoUrl/guestAuth/app/rest/builds/buildType:(id:$teamCityProjectId),number:$teamCityBuildNumber,$query/artifacts/content/maven/" + + applyBootstrapConfiguration( + bootstrapVersion, + bootstrapRepo, + isJpsBuildEnabled.get(), + "Using Kotlin TeamCity bootstrap version $bootstrapVersion from $bootstrapRepo" + ) + } + customBootstrapVersion.orNull != null -> { + val bootstrapVersion = customBootstrapVersion.get() + val bootstrapRepo = customBootstrapRepo.get() + + applyBootstrapConfiguration( + bootstrapVersion, + bootstrapRepo, + isJpsBuildEnabled.get(), + "Using Kotlin custom bootstrap version $bootstrapVersion from $bootstrapRepo" + ) + } + else -> { + val bootstrapVersion = defaultBootstrapVersion.get() + val bootstrapRepo = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap" + + applyBootstrapConfiguration( + bootstrapVersion, + bootstrapRepo, + isJpsBuildEnabled.get(), + "Using Kotlin Space bootstrap version $bootstrapVersion from $bootstrapRepo" + ) + } +} diff --git a/settings.gradle b/settings.gradle index 5662b729fa8..e48b006a983 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,13 +1,8 @@ pluginManagement { apply from: 'repo/scripts/cache-redirector.settings.gradle.kts' + apply from: 'repo/scripts/kotlin-bootstrap.settings.gradle.kts' repositories { - def pluginRepo = System.getProperty("bootstrap.kotlin.repo") - if (pluginRepo != null) { - maven { - url pluginRepo - } - } maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } mavenCentral() gradlePluginPortal()