Skip to content

Commit 2b69cf0

Browse files
authored
Replace the rest of Gradle scripts with gradle.kts, extract test utilities to a separate module (#4011)
2 parents 648ba8a + 555c65f commit 2b69cf0

File tree

514 files changed

+2191
-1888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+2191
-1888
lines changed

build.gradle

Lines changed: 0 additions & 164 deletions
This file was deleted.

build.gradle.kts

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

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ dependencies {
6161
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
6262
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
6363
}
64-
64+
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.9")
6565
implementation("org.jetbrains.kotlinx:kotlinx-knit:${version("knit")}")
6666
}

buildSrc/src/main/kotlin/OptInPreset.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.

buildSrc/src/main/kotlin/Projects.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ val Project.sourceSets: SourceSetContainer
2424

2525
val coreModule = "kotlinx-coroutines-core"
2626
val jdk8ObsoleteModule = "kotlinx-coroutines-jdk8"
27-
val testModule = "kotlinx-coroutines-test"
27+
val testUtilsModule = "test-utils"
2828

2929
// Not applicable for Kotlin plugin
3030
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom")
3131

3232
// Not published
33-
val unpublished = setOf("kotlinx.coroutines", "benchmarks", "android-unit-tests")
33+
val unpublished = setOf("kotlinx.coroutines", "benchmarks", "android-unit-tests", testUtilsModule)
3434

35-
val Project.isMultiplatform: Boolean get() = name in setOf(coreModule, testModule)
35+
val Project.isMultiplatform: Boolean get() = name in setOf(coreModule, "kotlinx-coroutines-test", testUtilsModule)
3636
val Project.isBom: Boolean get() = name == "kotlinx-coroutines-bom"
3737

3838
// Projects that we do not check for Android API level 14 check due to various limitations

0 commit comments

Comments
 (0)