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