1 /*
2 * Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5 import kotlinx.validation.*
6 import org.jetbrains.dokka.gradle.*
7
<lambda>null8 plugins {
9 base
10 alias(libs.plugins.knit)
11 id("org.jetbrains.kotlinx.binary-compatibility-validator")
12 id("org.jetbrains.dokka")
13 id("benchmark-conventions")
14 id("publishing-check-conventions")
15 id("kover-conventions")
16
17 alias(libs.plugins.serialization) apply false
18 }
19
<lambda>null20 repositories {
21 mavenCentral()
22 maven("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev")
23 // kotlin-dev with space redirector
24 maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
25 // For Dokka that depends on kotlinx-html
26 maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
27 // For local development
28 mavenLocal()
29 }
30
31 // == common projects settings setup
<lambda>null32 allprojects {
33 // group setup
34 group = "org.jetbrains.kotlinx"
35
36 // version setup
37 val deployVersion = properties["DeployVersion"]
38 if (deployVersion != null) version = deployVersion
39 if (project.hasProperty("bootstrap")) {
40 version = "$version-SNAPSHOT"
41 }
42
43 // repositories setup
44 if (propertyIsTrue("build_snapshot_train")) {
45 // Snapshot-specific
46 repositories {
47 mavenLocal()
48 maven("https://oss.sonatype.org/content/repositories/snapshots")
49 }
50 }
51 val snapshotRepoUrl = findProperty("kotlin_repo_url")
52 if (snapshotRepoUrl != null && snapshotRepoUrl != "") {
53 // Snapshot-specific for K2 CI configurations
54 repositories {
55 maven(snapshotRepoUrl)
56 }
57 }
58 repositories {
59 mavenCentral()
60 maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
61 }
62 }
63
64 // == BCV setup ==
<lambda>null65 apiValidation {
66 ignoredProjects.addAll(listOf("benchmark", "guide", "kotlinx-serialization", "kotlinx-serialization-json-tests"))
67 @OptIn(ExperimentalBCVApi::class)
68 klib {
69 enabled = true
70 }
71 }
72
73 // == Knit setup ==
74
<lambda>null75 knit {
76 siteRoot = "https://kotlinlang.org/api/kotlinx.serialization"
77 moduleDocs = "build/dokka/htmlMultiModule"
78 }
79
80 // Build API docs for all modules with dokka before running Knit
<lambda>null81 tasks.named("knitPrepare") {
82 dependsOn("dokka")
83 }
84
85
86 // == compiler flags setup ==
87
<lambda>null88 tasks.withType<org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile>().configureEach {
89 compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
90 }
<lambda>null91 tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile>().configureEach {
92 compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
93 }
94
<lambda>null95 subprojects {
96 tasks.withType<org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile<*>>().configureEach {
97 compilerOptions.freeCompilerArgs.addAll(globalCompilerArgs)
98 }
99 }
100
101 // == TeamCity setup ==
<lambda>null102 subprojects {
103 apply(plugin = "teamcity-conventions")
104 }
105
106 // == publishing setup ==
<lambda>null107 subprojects {
108 if (name in unpublishedProjects) return@subprojects
109 apply(plugin = "publishing-conventions")
110 }
111
112 // == publishing setup ==
113
114 val mergeProject = project
115
<lambda>null116 subprojects {
117 if (name in unpublishedProjects) return@subprojects
118 apply(plugin = "publishing-conventions")
119 mergeProject.dependencies.add(Publishing_check_conventions_gradle.TestPublishing.configurationName, this)
120 }
121
122 // == animalsniffer setup ==
<lambda>null123 subprojects {
124 // Can't be applied to BOM
125 if (project.name in excludedFromBomProjects) return@subprojects
126 apply(plugin = "animalsniffer-conventions")
127 }
128
129 // == BOM setup ==
<lambda>null130 subprojects {
131 // Can't be applied to BOM
132 if (project.name in excludedFromBomProjects) return@subprojects
133 apply(plugin = "bom-conventions")
134 }
135
136 // == Dokka setup ==
<lambda>null137 subprojects {
138 if (name in documentedSubprojects) {
139 apply(plugin = "dokka-conventions")
140 }
141 }
142
143 // Knit relies on Dokka task and it's pretty convenient
<lambda>null144 tasks.register("dokka") {
145 dependsOn("dokkaHtmlMultiModule")
146 }
147
<lambda>null148 tasks.withType<DokkaMultiModuleTask>().named("dokkaHtmlMultiModule") {
149 pluginsMapConfiguration.put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "${projectDir.toString().replace("\\", "/")}/dokka-templates" }""")
150 }
151
<lambda>null152 dependencies {
153 dokkaPlugin(libs.dokka.pathsaver)
154 }
155
156 // == NPM setup ==
157
<lambda>null158 tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
159 args.add("--ignore-engines")
160 }
161
162 // == compiler version setup ==
<lambda>null163 gradle.taskGraph.whenReady {
164 println("Using Kotlin compiler version: ${org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION}")
165 }
166
167 // == projects lists and flags ==
168 // getters are required because of variable lazy initialization in Gradle
169 val unpublishedProjects get() = setOf("benchmark", "guide", "kotlinx-serialization-json-tests")
170 val excludedFromBomProjects get() = unpublishedProjects + "kotlinx-serialization-bom"
171 val globalCompilerArgs
172 get() = listOf(
173 "-P", "plugin:org.jetbrains.kotlinx.serialization:disableIntrinsic=false"
174 )
175
176 val documentedSubprojects get() = setOf("kotlinx-serialization-core",
177 "kotlinx-serialization-json",
178 "kotlinx-serialization-json-okio",
179 "kotlinx-serialization-json-io",
180 "kotlinx-serialization-cbor",
181 "kotlinx-serialization-properties",
182 "kotlinx-serialization-hocon",
183 "kotlinx-serialization-protobuf")
184