summaryrefslogtreecommitdiff
path: root/buildSrc/build.gradle.kts
blob: c999bcd262bebf844bf0e4c446da1e6944de1cdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

import java.util.*
import java.io.FileInputStream

plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
    mavenLocal()
    if (project.hasProperty("kotlin_repo_url")) {
        maven(project.properties["kotlin_repo_url"] as String)
    }
    // kotlin-dev with space redirector
    maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
}

val kotlinVersion = run {
    if (project.hasProperty("build_snapshot_train")) {
        val ver = project.properties["kotlin_snapshot_version"] as? String
        require(!ver.isNullOrBlank()) {"kotlin_snapshot_version must be present if build_snapshot_train is used" }
        return@run ver
    }
    if (project.hasProperty("kotlin_repo_url")) {
        val ver = project.properties["kotlin_version"] as? String
        require(!ver.isNullOrBlank()) {"kotlin_version must be present if kotlin_repo_url is used" }
        return@run ver
    }
    val targetProp = if (project.hasProperty("bootstrap")) "kotlin.version.snapshot" else "kotlin.version"
    FileInputStream(file("../gradle.properties")).use { propFile ->
        val ver = project.findProperty("kotlin.version")?.toString() ?: Properties().apply { load(propFile) }[targetProp]
        require(ver is String) { "$targetProp must be string in ../gradle.properties, got $ver instead" }
        ver
    }
}

dependencies {
    implementation(kotlin("gradle-plugin", kotlinVersion))
}