Provide kotlin bootstrap source options
This commit is contained in:
+7
-5
@@ -6,14 +6,16 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
|
||||
buildscript {
|
||||
extra["defaultSnapshotVersion"] = "1.1-SNAPSHOT"
|
||||
|
||||
kotlinBootstrapFrom(BootstrapOption.BintrayDev("1.1.50-dev-1451"))
|
||||
|
||||
val repos = listOfNotNull(
|
||||
property("bootstrap.kotlin.repo") as String,
|
||||
"https://repo.gradle.org/gradle/repo",
|
||||
bootstrapKotlinRepo,
|
||||
"https://jcenter.bintray.com/",
|
||||
"https://plugins.gradle.org/m2",
|
||||
"http://repository.jetbrains.com/utils/")
|
||||
|
||||
extra["bootstrapKotlinVersion"] = bootstrapKotlinVersion
|
||||
|
||||
extra["repos"] = repos
|
||||
|
||||
extra["versions.shadow"] = "2.0.1"
|
||||
@@ -46,7 +48,7 @@ val configuredJdks: List<JdkId> =
|
||||
}
|
||||
}
|
||||
|
||||
val defaultSnapshotVersion = "1.1-SNAPSHOT"
|
||||
val defaultSnapshotVersion: String by extra
|
||||
val buildNumber by extra(findProperty("build.number")?.toString() ?: defaultSnapshotVersion)
|
||||
val kotlinVersion by extra(findProperty("deployVersion")?.toString() ?: buildNumber)
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
|
||||
var Project.bootstrapKotlinVersion: String
|
||||
get() = this.property("bootstrapKotlinVersion") as String
|
||||
private set(value) { this.extra["bootstrapKotlinVersion"] = value }
|
||||
var Project.bootstrapKotlinRepo: String?
|
||||
get() = this.property("bootstrapKotlinRepo") as String?
|
||||
private set(value) { this.extra["bootstrapKotlinRepo"] = value }
|
||||
|
||||
fun Project.kotlinBootstrapFrom(defaultSource: BootstrapOption) {
|
||||
val bootstrapVersion = project.findProperty("bootstrap.kotlin.version") as String?
|
||||
val bootstrapRepo = project.findProperty("bootstrap.kotlin.repo") as String?
|
||||
val bootstrapTeamCityVersion = project.findProperty("bootstrap.teamcity.kotlin.version") as String?
|
||||
|
||||
val bootstrapSource = when {
|
||||
project.hasProperty("bootstrap.local") -> BootstrapOption.Local(project.findProperty("bootstrap.local.version") as String?, project.findProperty("bootstrap.local.path") as String?)
|
||||
bootstrapTeamCityVersion != null -> BootstrapOption.TeamCity(bootstrapTeamCityVersion, onlySuccessBootstrap = false)
|
||||
bootstrapVersion != null -> BootstrapOption.Custom(kotlinVersion = bootstrapVersion, repo = bootstrapRepo)
|
||||
else -> defaultSource
|
||||
}
|
||||
|
||||
bootstrapSource.applyToProject(project)
|
||||
project.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?) : BootstrapOption() {
|
||||
override fun applyToProject(project: Project) {
|
||||
project.bootstrapKotlinVersion = kotlinVersion
|
||||
project.bootstrapKotlinRepo = repo
|
||||
}
|
||||
}
|
||||
|
||||
/** Get bootstrap from kotlin-dev bintray repo, where bootstraps are published */
|
||||
class BintrayDev(kotlinVersion: String) : Custom(kotlinVersion, "https://dl.bintray.com/kotlin/kotlin-dev")
|
||||
|
||||
/** Get bootstrap from teamcity maven artifacts of the specified build configuration
|
||||
*
|
||||
* [kotlinVersion] build number and the version of maven artifacts
|
||||
* [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 projectExtId: String? = null, val onlySuccessBootstrap: Boolean = true) : BootstrapOption() {
|
||||
override fun applyToProject(project: Project) {
|
||||
val query = if (onlySuccessBootstrap) "status:SUCCESS,tag:bootstrap,pinned:true" else "branch:default:any"
|
||||
project.bootstrapKotlinRepo = "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:${projectExtId ?: "Kotlin_dev_Compiler"}),number:$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 repoPath = if (localPath != null)
|
||||
project.projectDir.resolve(localPath).canonicalFile
|
||||
else
|
||||
project.buildDir.resolve("repo")
|
||||
|
||||
project.bootstrapKotlinRepo = repoPath.toURI().toString()
|
||||
project.bootstrapKotlinVersion = kotlinVersion ?: project.property("defaultSnapshotVersion") as String
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,7 @@ import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
val Project.bootstrapKotlinVersion: String get() = this.property("bootstrap.kotlin.version") as String
|
||||
|
||||
fun Project.commonDep(coord: String): String {
|
||||
val parts = coord.split(':')
|
||||
|
||||
+2
-2
@@ -3,6 +3,6 @@ org.gradle.parallel=false
|
||||
org.gradle.configureondemand=false
|
||||
org.gradle.jvmargs=-Xmx1000m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
|
||||
|
||||
bootstrap.kotlin.repo=https://dl.bintray.com/kotlin/kotlin-dev
|
||||
bootstrap.kotlin.version=1.1.50-dev-1451
|
||||
#bootstrap.kotlin.repo=https://dl.bintray.com/kotlin/kotlin-dev
|
||||
#bootstrap.kotlin.version=1.1.50-dev-1451
|
||||
#signingRequired=true
|
||||
|
||||
Reference in New Issue
Block a user