blob: 69aa68dd173ea42a6ae2599be22832481061b274 [file] [log] [blame]
Roman Elizarov26af9192017-09-21 18:12:04 +03001/*
Leonid Startsev21dea852021-05-18 18:36:19 +03002 * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarov26af9192017-09-21 18:12:04 +03003 */
4
Leonid Startsev08d3ca02017-07-26 15:16:23 +03005buildscript {
Leonid Startsevca620912017-11-09 19:55:51 +03006 if (project.hasProperty("bootstrap")) {
Leonid Startsev45aa7c72019-04-23 21:29:03 +03007 ext.kotlin_version = property('kotlin.version.snapshot')
Leonid Startsevcea9b432019-11-19 14:14:26 +03008 ext["kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST")
Leonid Startsevca620912017-11-09 19:55:51 +03009 } else {
Leonid Startsev45aa7c72019-04-23 21:29:03 +030010 ext.kotlin_version = property('kotlin.version')
Leonid Startsevca620912017-11-09 19:55:51 +030011 }
Leonid Startsev78d5d2d2019-07-25 13:51:54 +030012 if (project.hasProperty("library.version")) {
13 ext.overriden_version = property('library.version')
14 }
Leonid Startsev9650a282022-05-11 14:55:47 +030015 ext.experimentalsEnabled = ["-progressive", "-opt-in=kotlin.Experimental",
16 "-opt-in=kotlin.ExperimentalMultiplatform",
17 "-opt-in=kotlinx.serialization.InternalSerializationApi"
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030018 ]
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030019
Leonid Startsev9650a282022-05-11 14:55:47 +030020 ext.experimentalsInTestEnabled = ["-progressive", "-opt-in=kotlin.Experimental",
21 "-opt-in=kotlin.ExperimentalMultiplatform",
22 "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
23 "-opt-in=kotlinx.serialization.InternalSerializationApi",
24 "-opt-in=kotlin.ExperimentalUnsignedTypes"
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030025 ]
Leonid Startseve721ebe2021-10-29 14:41:49 +030026 ext.koverEnabled = property('kover.enabled') ?: true
Leonid Startsev08d3ca02017-07-26 15:16:23 +030027
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030028 /*
Leonid Startsevcea9b432019-11-19 14:14:26 +030029 * This property group is used to build kotlinx.serialization against Kotlin compiler snapshot.
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030030 * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version.
31 * DO NOT change the name of these properties without adapting kotlinx.train build chain.
32 */
33 def prop = rootProject.properties['build_snapshot_train']
34 ext.build_snapshot_train = prop != null && prop != ""
35 if (build_snapshot_train) {
36 ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
37 if (kotlin_version == null) {
38 throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
39 }
40 repositories {
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030041 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030042 }
43 }
44
Leonid Startsev08d3ca02017-07-26 15:16:23 +030045 repositories {
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -070046 maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
Leonid Startsevfc9343f2021-04-26 15:18:02 +030047 // kotlin-dev with space redirector
48 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
Leonid Startsev6a8dc862021-02-04 17:03:31 +030049 mavenCentral()
Leonid Startsev45aa7c72019-04-23 21:29:03 +030050 gradlePluginPortal()
Vsevolod Tolstopyatov6d2e5cf2021-03-17 15:00:40 +030051 // For Dokka that depends on kotlinx-html
Leonid Startsev9f8d0502021-07-08 12:12:06 +030052 maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" }
Leonid Startsev0e75d252021-09-01 15:07:44 +030053 mavenLocal()
Leonid Startsev08d3ca02017-07-26 15:16:23 +030054 }
55
Leonid Startsevd656e5a2019-06-14 12:06:23 +030056 configurations.classpath {
57 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
58 if (details.requested.group == 'org.jetbrains.kotlin') {
59 details.useVersion kotlin_version
60 }
61 }
62 }
63
Leonid Startsev08d3ca02017-07-26 15:16:23 +030064 dependencies {
Leonid Startsev45aa7c72019-04-23 21:29:03 +030065 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
66 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030067 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
Leonid Startseve721ebe2021-10-29 14:41:49 +030068 classpath "org.jetbrains.kotlinx:kover:$kover_version"
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070069 classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$validator_version"
Roman Elizarov5459c102020-08-11 12:27:36 +030070 classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +030071 classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.3' // Android API check
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030072
Sebastian Schuberthece9fdd2022-01-28 16:23:48 +010073 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
Leonid Startsevbae49f92018-05-03 19:57:01 +030074
Leonid Startsev45aa7c72019-04-23 21:29:03 +030075 // Various benchmarking stuff
76 classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
Mark Kosichkinc5672e92021-05-24 21:38:20 +030077 classpath "me.champeau.gradle:jmh-gradle-plugin:0.5.3"
Leonid Startsev45aa7c72019-04-23 21:29:03 +030078 classpath "net.ltgt.gradle:gradle-apt-plugin:0.21"
Leonid Startsev08d3ca02017-07-26 15:16:23 +030079 }
80}
81
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +030082// To make it visible for compiler-version.gradle
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030083ext.compilerVersion = org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION
Vsevolod Tolstopyatov07f730a2021-01-22 03:32:08 -080084ext.nativeDebugBuild = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +030085
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070086apply plugin: 'binary-compatibility-validator'
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +030087apply plugin: 'base'
88apply plugin: 'kotlinx-knit'
Leonid Startsev45aa7c72019-04-23 21:29:03 +030089
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070090apiValidation {
Roman Elizarov5459c102020-08-11 12:27:36 +030091 ignoredProjects += ["benchmark", "guide", "kotlinx-serialization"]
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070092}
Leonid Startsev00dd4f52017-08-23 16:09:21 +030093
Roman Elizarov5459c102020-08-11 12:27:36 +030094knit {
95 siteRoot = "https://kotlin.github.io/kotlinx.serialization"
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -070096 moduleDocs = "build/dokka/htmlMultiModule"
Roman Elizarov5459c102020-08-11 12:27:36 +030097}
98
99// Build API docs for all modules with dokka before running Knit
100knitPrepare.dependsOn "dokka"
101
Ignat Beresnev8be68452021-12-27 18:40:50 +0300102apply plugin: 'org.jetbrains.dokka'
103dependencies {
104 dokkaPlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
105}
106
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300107allprojects {
108 group 'org.jetbrains.kotlinx'
Leonid Startsev476b7222018-06-26 17:06:14 +0300109
Leonid Startsevf5accd12020-02-25 20:42:46 +0300110 def deployVersion = properties['DeployVersion']
111 if (deployVersion != null) version = deployVersion
Leonid Startsev78d5d2d2019-07-25 13:51:54 +0300112
Leonid Startsev476b7222018-06-26 17:06:14 +0300113 if (project.hasProperty("bootstrap")) {
114 version = version + '-SNAPSHOT'
115 }
Leonid Startsev84062e12017-09-25 16:41:38 +0300116
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300117 // the only place where HostManager could be instantiated
118 project.ext.hostManager = new org.jetbrains.kotlin.konan.target.HostManager()
119
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300120 if (build_snapshot_train) {
121 // Snapshot-specific
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300122 repositories {
123 mavenLocal()
124 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
125 }
126 }
Leonid Startsevcf1db5c2019-09-17 19:33:44 +0300127
128 configurations.all {
129 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
130 if (details.requested.group == 'org.jetbrains.kotlin') {
131 details.useVersion kotlin_version
132 }
133 }
134 }
135
Leonid Startsev84062e12017-09-25 16:41:38 +0300136 repositories {
Leonid Startsev6a8dc862021-02-04 17:03:31 +0300137 mavenCentral()
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -0700138 maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
Vsevolod Tolstopyatov6d2e5cf2021-03-17 15:00:40 +0300139 // kotlin-dev with space redirector
140 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
141 // For Dokka that depends on kotlinx-html
Leonid Startsev9f8d0502021-07-08 12:12:06 +0300142 maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" }
Vsevolod Tolstopyatov6d2e5cf2021-03-17 15:00:40 +0300143 // For local development
144 mavenLocal()
Leonid Startsev9f8d0502021-07-08 12:12:06 +0300145
Leonid Startsev84062e12017-09-25 16:41:38 +0300146 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300147}
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300148
Leonid Startsev1c35d912017-10-04 12:26:43 +0300149subprojects {
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300150 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
151 if (task.name.contains("Test") || task.name.contains("Jmh")) {
152 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
153 } else {
154 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
155 }
156 }
157
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300158 apply from: rootProject.file('gradle/teamcity.gradle')
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300159 // Configure publishing for some artifacts
Roman Elizarov5459c102020-08-11 12:27:36 +0300160 if (project.name != "benchmark" && project.name != "guide") {
161 apply from: rootProject.file('gradle/publishing.gradle')
162 }
163
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300164}
Leonid Startseved87fbd2017-08-04 17:33:09 +0300165
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +0300166subprojects {
167 // Can't be applied to BOM
Leonid Startseve721ebe2021-10-29 14:41:49 +0300168 if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark" || project.name == "guide") return
169
170 // Animalsniffer setup
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +0300171 apply plugin: 'ru.vyarus.animalsniffer'
172
173 afterEvaluate { // Can be applied only when the project is evaluated
174 animalsniffer {
175 sourceSets = [sourceSets.main]
176 }
177 dependencies {
178 signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature'
179 signature 'org.codehaus.mojo.signature:java18:1.0@signature'
180 }
181 }
Leonid Startseve721ebe2021-10-29 14:41:49 +0300182
183 // Kover setup
184 apply from: rootProject.file("gradle/kover.gradle")
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +0300185}
186
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +0300187apply from: rootProject.file('gradle/compiler-version.gradle')
Leonid Startsevbc9c8f42020-04-06 22:30:25 +0300188apply from: rootProject.file("gradle/dokka.gradle")
Leonid Startsev98ead982021-06-28 13:02:07 +0300189apply from: rootProject.file("gradle/benchmark-parsing.gradle")