-
Notifications
You must be signed in to change notification settings - Fork 622
/
build.gradle.kts
183 lines (152 loc) · 5.27 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import kotlinx.validation.*
import org.jetbrains.dokka.gradle.*
plugins {
base
alias(libs.plugins.knit)
id("org.jetbrains.kotlinx.binary-compatibility-validator")
id("org.jetbrains.dokka")
id("benchmark-conventions")
id("publishing-check-conventions")
id("kover-conventions")
alias(libs.plugins.serialization) apply false
}
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev")
// kotlin-dev with space redirector
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
// For Dokka that depends on kotlinx-html
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
// For local development
mavenLocal()
}
// == common projects settings setup
allprojects {
// group setup
group = "org.jetbrains.kotlinx"
// version setup
val deployVersion = properties["DeployVersion"]
if (deployVersion != null) version = deployVersion
if (project.hasProperty("bootstrap")) {
version = "$version-SNAPSHOT"
}
// repositories setup
if (propertyIsTrue("build_snapshot_train")) {
// Snapshot-specific
repositories {
mavenLocal()
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
}
val snapshotRepoUrl = findProperty("kotlin_repo_url")
if (snapshotRepoUrl != null && snapshotRepoUrl != "") {
// Snapshot-specific for K2 CI configurations
repositories {
maven(snapshotRepoUrl)
}
}
repositories {
mavenCentral()
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
}
}
// == BCV setup ==
apiValidation {
ignoredProjects.addAll(listOf("benchmark", "guide", "kotlinx-serialization", "kotlinx-serialization-json-tests"))
@OptIn(ExperimentalBCVApi::class)
klib {
enabled = true
}
}
// == Knit setup ==
knit {
siteRoot = "https://kotlinlang.org/api/kotlinx.serialization"
moduleDocs = "build/dokka/htmlMultiModule"
}
// Build API docs for all modules with dokka before running Knit
tasks.named("knitPrepare") {
dependsOn("dokka")
}
// == compiler flags setup ==
tasks.withType<org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile>().configureEach {
compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile>().configureEach {
compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
}
subprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile<*>>().configureEach {
compilerOptions.freeCompilerArgs.addAll(globalCompilerArgs)
}
}
// == TeamCity setup ==
subprojects {
apply(plugin = "teamcity-conventions")
}
// == publishing setup ==
subprojects {
if (name in unpublishedProjects) return@subprojects
apply(plugin = "publishing-conventions")
}
// == publishing setup ==
val mergeProject = project
subprojects {
if (name in unpublishedProjects) return@subprojects
apply(plugin = "publishing-conventions")
mergeProject.dependencies.add(Publishing_check_conventions_gradle.TestPublishing.configurationName, this)
}
// == animalsniffer setup ==
subprojects {
// Can't be applied to BOM
if (project.name in excludedFromBomProjects) return@subprojects
apply(plugin = "animalsniffer-conventions")
}
// == BOM setup ==
subprojects {
// Can't be applied to BOM
if (project.name in excludedFromBomProjects) return@subprojects
apply(plugin = "bom-conventions")
}
// == Dokka setup ==
subprojects {
if (name in documentedSubprojects) {
apply(plugin = "dokka-conventions")
}
}
// Knit relies on Dokka task and it's pretty convenient
tasks.register("dokka") {
dependsOn("dokkaHtmlMultiModule")
}
tasks.withType<DokkaMultiModuleTask>().named("dokkaHtmlMultiModule") {
pluginsMapConfiguration.put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "${projectDir.toString().replace("\\", "/")}/dokka-templates" }""")
}
dependencies {
dokkaPlugin(libs.dokka.pathsaver)
}
// == NPM setup ==
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
// == compiler version setup ==
gradle.taskGraph.whenReady {
println("Using Kotlin compiler version: ${org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION}")
}
// == projects lists and flags ==
// getters are required because of variable lazy initialization in Gradle
val unpublishedProjects get() = setOf("benchmark", "guide", "kotlinx-serialization-json-tests")
val excludedFromBomProjects get() = unpublishedProjects + "kotlinx-serialization-bom"
val globalCompilerArgs
get() = listOf(
"-P", "plugin:org.jetbrains.kotlinx.serialization:disableIntrinsic=false"
)
val documentedSubprojects get() = setOf("kotlinx-serialization-core",
"kotlinx-serialization-json",
"kotlinx-serialization-json-okio",
"kotlinx-serialization-json-io",
"kotlinx-serialization-cbor",
"kotlinx-serialization-properties",
"kotlinx-serialization-hocon",
"kotlinx-serialization-protobuf")