1*7a7160feSAndroid Build Coastguard Worker import java.util.*
2*7a7160feSAndroid Build Coastguard Worker
<lambda>null3*7a7160feSAndroid Build Coastguard Worker plugins {
4*7a7160feSAndroid Build Coastguard Worker `kotlin-dsl`
5*7a7160feSAndroid Build Coastguard Worker }
6*7a7160feSAndroid Build Coastguard Worker
7*7a7160feSAndroid Build Coastguard Worker val cacheRedirectorEnabled = System.getenv("CACHE_REDIRECTOR")?.toBoolean() == true
8*7a7160feSAndroid Build Coastguard Worker val buildSnapshotTrain = properties["build_snapshot_train"]?.toString()?.toBoolean() == true
9*7a7160feSAndroid Build Coastguard Worker val kotlinDevUrl = project.rootProject.properties["kotlin_repo_url"] as? String
10*7a7160feSAndroid Build Coastguard Worker
<lambda>null11*7a7160feSAndroid Build Coastguard Worker repositories {
12*7a7160feSAndroid Build Coastguard Worker mavenCentral()
13*7a7160feSAndroid Build Coastguard Worker if (cacheRedirectorEnabled) {
14*7a7160feSAndroid Build Coastguard Worker maven("https://cache-redirector.jetbrains.com/plugins.gradle.org/m2")
15*7a7160feSAndroid Build Coastguard Worker } else {
16*7a7160feSAndroid Build Coastguard Worker maven("https://plugins.gradle.org/m2")
17*7a7160feSAndroid Build Coastguard Worker }
18*7a7160feSAndroid Build Coastguard Worker if (!kotlinDevUrl.isNullOrEmpty()) {
19*7a7160feSAndroid Build Coastguard Worker maven(kotlinDevUrl)
20*7a7160feSAndroid Build Coastguard Worker }
21*7a7160feSAndroid Build Coastguard Worker if (buildSnapshotTrain) {
22*7a7160feSAndroid Build Coastguard Worker mavenLocal()
23*7a7160feSAndroid Build Coastguard Worker }
24*7a7160feSAndroid Build Coastguard Worker }
25*7a7160feSAndroid Build Coastguard Worker
<lambda>null26*7a7160feSAndroid Build Coastguard Worker val gradleProperties = Properties().apply {
27*7a7160feSAndroid Build Coastguard Worker file("../gradle.properties").inputStream().use { load(it) }
28*7a7160feSAndroid Build Coastguard Worker }
29*7a7160feSAndroid Build Coastguard Worker
versionnull30*7a7160feSAndroid Build Coastguard Worker fun version(target: String): String {
31*7a7160feSAndroid Build Coastguard Worker // Intercept reading from properties file
32*7a7160feSAndroid Build Coastguard Worker if (target == "kotlin") {
33*7a7160feSAndroid Build Coastguard Worker val snapshotVersion = properties["kotlin_snapshot_version"]
34*7a7160feSAndroid Build Coastguard Worker if (snapshotVersion != null) return snapshotVersion.toString()
35*7a7160feSAndroid Build Coastguard Worker }
36*7a7160feSAndroid Build Coastguard Worker val version = "${target}_version"
37*7a7160feSAndroid Build Coastguard Worker // Read from CLI first, used in aggregate builds
38*7a7160feSAndroid Build Coastguard Worker return properties[version]?.let{"$it"} ?: gradleProperties.getProperty(version)
39*7a7160feSAndroid Build Coastguard Worker }
40*7a7160feSAndroid Build Coastguard Worker
<lambda>null41*7a7160feSAndroid Build Coastguard Worker dependencies {
42*7a7160feSAndroid Build Coastguard Worker implementation(kotlin("gradle-plugin", version("kotlin")))
43*7a7160feSAndroid Build Coastguard Worker /*
44*7a7160feSAndroid Build Coastguard Worker * Dokka is compiled with language level = 1.4, but depends on Kotlin 1.6.0, while
45*7a7160feSAndroid Build Coastguard Worker * our version of Gradle bundles Kotlin 1.4.x and can read metadata only up to 1.5.x,
46*7a7160feSAndroid Build Coastguard Worker * thus we're excluding stdlib compiled with 1.6.0 from dependencies.
47*7a7160feSAndroid Build Coastguard Worker */
48*7a7160feSAndroid Build Coastguard Worker implementation("org.jetbrains.dokka:dokka-gradle-plugin:${version("dokka")}") {
49*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
50*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
51*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
52*7a7160feSAndroid Build Coastguard Worker }
53*7a7160feSAndroid Build Coastguard Worker implementation("org.jetbrains.dokka:dokka-core:${version("dokka")}") {
54*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
55*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
56*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
57*7a7160feSAndroid Build Coastguard Worker }
58*7a7160feSAndroid Build Coastguard Worker implementation("ru.vyarus:gradle-animalsniffer-plugin:${version("animalsniffer")}") // Android API check
59*7a7160feSAndroid Build Coastguard Worker implementation("org.jetbrains.kotlinx:kover-gradle-plugin:${version("kover")}") {
60*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
61*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
62*7a7160feSAndroid Build Coastguard Worker exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
63*7a7160feSAndroid Build Coastguard Worker }
64*7a7160feSAndroid Build Coastguard Worker implementation("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.9")
65*7a7160feSAndroid Build Coastguard Worker implementation("org.jetbrains.kotlinx:kotlinx-knit:${version("knit")}")
66*7a7160feSAndroid Build Coastguard Worker }
67