1*7a7160feSAndroid Build Coastguard Worker import org.jetbrains.kotlin.config.KotlinCompilerVersion 2*7a7160feSAndroid Build Coastguard Worker import org.jetbrains.kotlin.gradle.dsl.* 3*7a7160feSAndroid Build Coastguard Worker import org.gradle.kotlin.dsl.* 4*7a7160feSAndroid Build Coastguard Worker <lambda>null5*7a7160feSAndroid Build Coastguard Workerbuildscript { 6*7a7160feSAndroid Build Coastguard Worker if (shouldUseLocalMaven(rootProject)) { 7*7a7160feSAndroid Build Coastguard Worker repositories { 8*7a7160feSAndroid Build Coastguard Worker mavenLocal() 9*7a7160feSAndroid Build Coastguard Worker } 10*7a7160feSAndroid Build Coastguard Worker } 11*7a7160feSAndroid Build Coastguard Worker 12*7a7160feSAndroid Build Coastguard Worker repositories { 13*7a7160feSAndroid Build Coastguard Worker mavenCentral() 14*7a7160feSAndroid Build Coastguard Worker maven(url = "https://plugins.gradle.org/m2/") 15*7a7160feSAndroid Build Coastguard Worker addDevRepositoryIfEnabled(this, project) 16*7a7160feSAndroid Build Coastguard Worker mavenLocal() 17*7a7160feSAndroid Build Coastguard Worker } 18*7a7160feSAndroid Build Coastguard Worker 19*7a7160feSAndroid Build Coastguard Worker dependencies { 20*7a7160feSAndroid Build Coastguard Worker // Please ensure that atomicfu-gradle-plugin is added to the classpath first, do not change the order, for details see #3984. 21*7a7160feSAndroid Build Coastguard Worker // The corresponding issue in kotlinx-atomicfu: https://github.com/Kotlin/kotlinx-atomicfu/issues/384 22*7a7160feSAndroid Build Coastguard Worker classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${version("atomicfu")}") 23*7a7160feSAndroid Build Coastguard Worker classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${version("kotlin")}") 24*7a7160feSAndroid Build Coastguard Worker classpath("org.jetbrains.dokka:dokka-gradle-plugin:${version("dokka")}") 25*7a7160feSAndroid Build Coastguard Worker classpath("org.jetbrains.kotlinx:kotlinx-knit:${version("knit")}") 26*7a7160feSAndroid Build Coastguard Worker classpath("org.jetbrains.kotlinx:binary-compatibility-validator:${version("binary_compatibility_validator")}") 27*7a7160feSAndroid Build Coastguard Worker classpath("ru.vyarus:gradle-animalsniffer-plugin:${version("animalsniffer")}") // Android API check 28*7a7160feSAndroid Build Coastguard Worker classpath("org.jetbrains.kotlin:atomicfu:${version("kotlin")}") 29*7a7160feSAndroid Build Coastguard Worker classpath("org.jetbrains.kotlinx:kover-gradle-plugin:${version("kover")}") 30*7a7160feSAndroid Build Coastguard Worker 31*7a7160feSAndroid Build Coastguard Worker // JMH plugins 32*7a7160feSAndroid Build Coastguard Worker classpath("gradle.plugin.com.github.johnrengelman:shadow:${version("shadow")}") 33*7a7160feSAndroid Build Coastguard Worker } 34*7a7160feSAndroid Build Coastguard Worker 35*7a7160feSAndroid Build Coastguard Worker with(CacheRedirector) { buildscript.configureBuildScript(rootProject) } 36*7a7160feSAndroid Build Coastguard Worker } 37*7a7160feSAndroid Build Coastguard Worker 38*7a7160feSAndroid Build Coastguard Worker // Configure subprojects with Kotlin sources 39*7a7160feSAndroid Build Coastguard Worker apply(plugin = "configure-compilation-conventions") 40*7a7160feSAndroid Build Coastguard Worker <lambda>null41*7a7160feSAndroid Build Coastguard Workerallprojects { 42*7a7160feSAndroid Build Coastguard Worker val deployVersion = properties["DeployVersion"] 43*7a7160feSAndroid Build Coastguard Worker if (deployVersion != null) version = deployVersion 44*7a7160feSAndroid Build Coastguard Worker 45*7a7160feSAndroid Build Coastguard Worker if (isSnapshotTrainEnabled(rootProject)) { 46*7a7160feSAndroid Build Coastguard Worker val skipSnapshotChecks = rootProject.properties["skip_snapshot_checks"] != null 47*7a7160feSAndroid Build Coastguard Worker if (!skipSnapshotChecks && version != version("atomicfu")) { 48*7a7160feSAndroid Build Coastguard Worker throw IllegalStateException("Current deploy version is $version, but atomicfu version is not overridden (${version("atomicfu")}) for $this") 49*7a7160feSAndroid Build Coastguard Worker } 50*7a7160feSAndroid Build Coastguard Worker } 51*7a7160feSAndroid Build Coastguard Worker 52*7a7160feSAndroid Build Coastguard Worker if (shouldUseLocalMaven(rootProject)) { 53*7a7160feSAndroid Build Coastguard Worker repositories { 54*7a7160feSAndroid Build Coastguard Worker mavenLocal() 55*7a7160feSAndroid Build Coastguard Worker } 56*7a7160feSAndroid Build Coastguard Worker } 57*7a7160feSAndroid Build Coastguard Worker 58*7a7160feSAndroid Build Coastguard Worker // This project property is set during nightly stress test 59*7a7160feSAndroid Build Coastguard Worker val stressTest = project.properties["stressTest"] 60*7a7160feSAndroid Build Coastguard Worker // Copy it to all test tasks 61*7a7160feSAndroid Build Coastguard Worker tasks.withType(Test::class).configureEach { 62*7a7160feSAndroid Build Coastguard Worker if (stressTest != null) { 63*7a7160feSAndroid Build Coastguard Worker systemProperty("stressTest", stressTest) 64*7a7160feSAndroid Build Coastguard Worker } 65*7a7160feSAndroid Build Coastguard Worker } 66*7a7160feSAndroid Build Coastguard Worker } 67*7a7160feSAndroid Build Coastguard Worker <lambda>null68*7a7160feSAndroid Build Coastguard Workerplugins { 69*7a7160feSAndroid Build Coastguard Worker id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" 70*7a7160feSAndroid Build Coastguard Worker } 71*7a7160feSAndroid Build Coastguard Worker 72*7a7160feSAndroid Build Coastguard Worker apply(plugin = "base") 73*7a7160feSAndroid Build Coastguard Worker apply(plugin = "kover-conventions") 74*7a7160feSAndroid Build Coastguard Worker <lambda>null75*7a7160feSAndroid Build Coastguard WorkerapiValidation { 76*7a7160feSAndroid Build Coastguard Worker ignoredProjects += unpublished + listOf("kotlinx-coroutines-bom") 77*7a7160feSAndroid Build Coastguard Worker if (isSnapshotTrainEnabled(rootProject)) { 78*7a7160feSAndroid Build Coastguard Worker ignoredProjects += coreModule 79*7a7160feSAndroid Build Coastguard Worker } 80*7a7160feSAndroid Build Coastguard Worker ignoredPackages += "kotlinx.coroutines.internal" 81*7a7160feSAndroid Build Coastguard Worker } 82*7a7160feSAndroid Build Coastguard Worker 83*7a7160feSAndroid Build Coastguard Worker // Configure repositories <lambda>null84*7a7160feSAndroid Build Coastguard Workerallprojects { 85*7a7160feSAndroid Build Coastguard Worker repositories { 86*7a7160feSAndroid Build Coastguard Worker /* 87*7a7160feSAndroid Build Coastguard Worker * google should be first in the repository list because some of the play services 88*7a7160feSAndroid Build Coastguard Worker * transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution 89*7a7160feSAndroid Build Coastguard Worker */ 90*7a7160feSAndroid Build Coastguard Worker google() 91*7a7160feSAndroid Build Coastguard Worker mavenCentral() 92*7a7160feSAndroid Build Coastguard Worker addDevRepositoryIfEnabled(this, project) 93*7a7160feSAndroid Build Coastguard Worker } 94*7a7160feSAndroid Build Coastguard Worker } 95*7a7160feSAndroid Build Coastguard Worker 96*7a7160feSAndroid Build Coastguard Worker // needs to be before evaluationDependsOn due to weird Gradle ordering 97*7a7160feSAndroid Build Coastguard Worker apply(plugin = "animalsniffer-conventions") 98*7a7160feSAndroid Build Coastguard Worker <lambda>null99*7a7160feSAndroid Build Coastguard Workerconfigure(subprojects.filter { !sourceless.contains(it.name) }) { 100*7a7160feSAndroid Build Coastguard Worker if (isMultiplatform) { 101*7a7160feSAndroid Build Coastguard Worker apply(plugin = "kotlin-multiplatform") 102*7a7160feSAndroid Build Coastguard Worker apply(plugin = "kotlin-multiplatform-conventions") 103*7a7160feSAndroid Build Coastguard Worker } else if (platformOf(this) == "jvm") { 104*7a7160feSAndroid Build Coastguard Worker apply(plugin = "kotlin-jvm-conventions") 105*7a7160feSAndroid Build Coastguard Worker } else { 106*7a7160feSAndroid Build Coastguard Worker val platform = platformOf(this) 107*7a7160feSAndroid Build Coastguard Worker throw IllegalStateException("No configuration rules for $platform") 108*7a7160feSAndroid Build Coastguard Worker } 109*7a7160feSAndroid Build Coastguard Worker } 110*7a7160feSAndroid Build Coastguard Worker <lambda>null111*7a7160feSAndroid Build Coastguard Workerconfigure(subprojects.filter { !sourceless.contains(it.name) && it.name != testUtilsModule }) { 112*7a7160feSAndroid Build Coastguard Worker if (isMultiplatform) { <lambda>null113*7a7160feSAndroid Build Coastguard Worker configure<KotlinMultiplatformExtension> { 114*7a7160feSAndroid Build Coastguard Worker sourceSets.commonTest.dependencies { implementation(project(":$testUtilsModule")) } 115*7a7160feSAndroid Build Coastguard Worker } 116*7a7160feSAndroid Build Coastguard Worker } else { <lambda>null117*7a7160feSAndroid Build Coastguard Worker dependencies { add("testImplementation", project(":$testUtilsModule")) } 118*7a7160feSAndroid Build Coastguard Worker } 119*7a7160feSAndroid Build Coastguard Worker } 120*7a7160feSAndroid Build Coastguard Worker 121*7a7160feSAndroid Build Coastguard Worker // Add dependency to the core module in all the other subprojects. <lambda>null122*7a7160feSAndroid Build Coastguard Workerconfigure(subprojects.filter { !sourceless.contains(it.name) && it.name != coreModule }) { 123*7a7160feSAndroid Build Coastguard Worker evaluationDependsOn(":$coreModule") 124*7a7160feSAndroid Build Coastguard Worker if (isMultiplatform) { <lambda>null125*7a7160feSAndroid Build Coastguard Worker configure<KotlinMultiplatformExtension> { 126*7a7160feSAndroid Build Coastguard Worker sourceSets.commonMain.dependencies { api(project(":$coreModule")) } 127*7a7160feSAndroid Build Coastguard Worker } 128*7a7160feSAndroid Build Coastguard Worker } else { <lambda>null129*7a7160feSAndroid Build Coastguard Worker dependencies { add("api", project(":$coreModule")) } 130*7a7160feSAndroid Build Coastguard Worker } 131*7a7160feSAndroid Build Coastguard Worker } 132*7a7160feSAndroid Build Coastguard Worker 133*7a7160feSAndroid Build Coastguard Worker apply(plugin = "bom-conventions") 134*7a7160feSAndroid Build Coastguard Worker apply(plugin = "java-modularity-conventions") 135*7a7160feSAndroid Build Coastguard Worker apply(plugin = "version-file-conventions") 136*7a7160feSAndroid Build Coastguard Worker 137*7a7160feSAndroid Build Coastguard Worker rootProject.configureCommunityBuildTweaks() 138*7a7160feSAndroid Build Coastguard Worker 139*7a7160feSAndroid Build Coastguard Worker apply(plugin = "source-set-conventions") 140*7a7160feSAndroid Build Coastguard Worker apply(plugin = "dokka-conventions") 141*7a7160feSAndroid Build Coastguard Worker apply(plugin = "knit-conventions") 142*7a7160feSAndroid Build Coastguard Worker 143*7a7160feSAndroid Build Coastguard Worker /* 144*7a7160feSAndroid Build Coastguard Worker * TODO: core and non-core cannot be configured via 'configure(subprojects)' 145*7a7160feSAndroid Build Coastguard Worker * because of 'afterEvaluate' issue. This one should be migrated to 146*7a7160feSAndroid Build Coastguard Worker * `plugins { id("pub-conventions") }` eventually 147*7a7160feSAndroid Build Coastguard Worker */ <lambda>null148*7a7160feSAndroid Build Coastguard Workerconfigure(subprojects.filter { 149*7a7160feSAndroid Build Coastguard Worker !unpublished.contains(it.name) && it.name != coreModule 150*7a7160feSAndroid Build Coastguard Worker }) { 151*7a7160feSAndroid Build Coastguard Worker apply(plugin = "pub-conventions") 152*7a7160feSAndroid Build Coastguard Worker } 153*7a7160feSAndroid Build Coastguard Worker 154*7a7160feSAndroid Build Coastguard Worker AuxBuildConfiguration.configure(rootProject) 155*7a7160feSAndroid Build Coastguard Worker rootProject.registerTopLevelDeployTask() 156*7a7160feSAndroid Build Coastguard Worker 157*7a7160feSAndroid Build Coastguard Worker // Report Kotlin compiler version when building project 158*7a7160feSAndroid Build Coastguard Worker println("Using Kotlin compiler version: ${KotlinCompilerVersion.VERSION}") 159*7a7160feSAndroid Build Coastguard Worker 160