From 1b5417e4228270a1282e0e06b73bb4b136d6869f Mon Sep 17 00:00:00 2001 From: Vyacheslav Gerasimov Date: Tue, 17 Sep 2019 17:01:42 +0300 Subject: [PATCH] Minor: Build use cache-redirector for bootstrap repos --- .idea/dictionaries/4u7.xml | 1 + buildSrc/src/main/kotlin/Bootstrap.kt | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.idea/dictionaries/4u7.xml b/.idea/dictionaries/4u7.xml index 103dc7c8eeb..ec16da6a994 100644 --- a/.idea/dictionaries/4u7.xml +++ b/.idea/dictionaries/4u7.xml @@ -1,6 +1,7 @@ + bintray cidr foldable instrumentator diff --git a/buildSrc/src/main/kotlin/Bootstrap.kt b/buildSrc/src/main/kotlin/Bootstrap.kt index a22c6ccc604..d254df9436d 100644 --- a/buildSrc/src/main/kotlin/Bootstrap.kt +++ b/buildSrc/src/main/kotlin/Bootstrap.kt @@ -2,6 +2,7 @@ import org.gradle.api.Project import org.gradle.kotlin.dsl.* +import java.net.URI var Project.bootstrapKotlinVersion: String @@ -52,18 +53,23 @@ sealed class BootstrapOption { * * If [repo] is not specified the default buildscript and project repositories are used */ - open class Custom(val kotlinVersion: String, val repo: String?) : BootstrapOption() { + open class Custom(val kotlinVersion: String, val repo: String?, val cacheRedirector: Boolean = false) : BootstrapOption() { override fun applyToProject(project: Project) { project.bootstrapKotlinVersion = kotlinVersion - project.bootstrapKotlinRepo = repo + project.bootstrapKotlinRepo = if (cacheRedirector) + repo?.let { URI(it) }?.let { "https://cache-redirector.jetbrains.com/${it.host}/${it.path}" } + else + repo } } /** Get bootstrap from kotlin-dev bintray repo */ - class BintrayDev(kotlinVersion: String) : Custom(kotlinVersion, "https://dl.bintray.com/kotlin/kotlin-dev") + class BintrayDev(kotlinVersion: String, cacheRedirector: Boolean = false) : + Custom(kotlinVersion, "https://dl.bintray.com/kotlin/kotlin-dev", cacheRedirector) /** Get bootstrap from kotlin-bootstrap bintray repo, where bootstraps are published */ - class BintrayBootstrap(kotlinVersion: String) : Custom(kotlinVersion, "https://dl.bintray.com/kotlin/kotlin-bootstrap") + class BintrayBootstrap(kotlinVersion: String, cacheRedirector: Boolean = false) : + Custom(kotlinVersion, "https://dl.bintray.com/kotlin/kotlin-bootstrap", cacheRedirector) /** Get bootstrap from teamcity maven artifacts of the specified build configuration *