blob: 235371708d8f2a95c7c62222e0ddc166e4dbd6ae [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 Startsevf7a71412021-08-12 15:33:10 +030015 ext.experimentalsEnabled = ["-progressive", "-Xopt-in=kotlin.Experimental",
16 "-Xopt-in=kotlin.ExperimentalMultiplatform",
17 "-Xopt-in=kotlinx.serialization.InternalSerializationApi"
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030018 ]
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030019
Leonid Startsevf7a71412021-08-12 15:33:10 +030020 ext.experimentalsInTestEnabled = ["-progressive", "-Xopt-in=kotlin.Experimental",
21 "-Xopt-in=kotlin.ExperimentalMultiplatform",
22 "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
23 "-Xopt-in=kotlinx.serialization.InternalSerializationApi",
24 "-Xopt-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
Leonid Startsev45aa7c72019-04-23 21:29:03 +030073 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
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
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300102allprojects {
103 group 'org.jetbrains.kotlinx'
Leonid Startsev476b7222018-06-26 17:06:14 +0300104
Leonid Startsevf5accd12020-02-25 20:42:46 +0300105 def deployVersion = properties['DeployVersion']
106 if (deployVersion != null) version = deployVersion
Leonid Startsev78d5d2d2019-07-25 13:51:54 +0300107
Leonid Startsev476b7222018-06-26 17:06:14 +0300108 if (project.hasProperty("bootstrap")) {
109 version = version + '-SNAPSHOT'
110 }
Leonid Startsev84062e12017-09-25 16:41:38 +0300111
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300112 // the only place where HostManager could be instantiated
113 project.ext.hostManager = new org.jetbrains.kotlin.konan.target.HostManager()
114
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300115 if (build_snapshot_train) {
116 // Snapshot-specific
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300117 repositories {
118 mavenLocal()
119 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
120 }
121 }
Leonid Startsevcf1db5c2019-09-17 19:33:44 +0300122
123 configurations.all {
124 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
125 if (details.requested.group == 'org.jetbrains.kotlin') {
126 details.useVersion kotlin_version
127 }
128 }
129 }
130
Leonid Startsev84062e12017-09-25 16:41:38 +0300131 repositories {
Leonid Startsev6a8dc862021-02-04 17:03:31 +0300132 mavenCentral()
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -0700133 maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
Vsevolod Tolstopyatov6d2e5cf2021-03-17 15:00:40 +0300134 // kotlin-dev with space redirector
135 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
136 // For Dokka that depends on kotlinx-html
Leonid Startsev9f8d0502021-07-08 12:12:06 +0300137 maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" }
Vsevolod Tolstopyatov6d2e5cf2021-03-17 15:00:40 +0300138 // For local development
139 mavenLocal()
Leonid Startsev9f8d0502021-07-08 12:12:06 +0300140
Leonid Startsev84062e12017-09-25 16:41:38 +0300141 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300142}
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300143
Leonid Startsev1c35d912017-10-04 12:26:43 +0300144subprojects {
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300145 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
146 if (task.name.contains("Test") || task.name.contains("Jmh")) {
147 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
148 } else {
149 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
150 }
151 }
152
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300153 apply from: rootProject.file('gradle/teamcity.gradle')
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300154 // Configure publishing for some artifacts
Roman Elizarov5459c102020-08-11 12:27:36 +0300155 if (project.name != "benchmark" && project.name != "guide") {
156 apply from: rootProject.file('gradle/publishing.gradle')
157 }
158
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300159}
Leonid Startseved87fbd2017-08-04 17:33:09 +0300160
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +0300161subprojects {
162 // Can't be applied to BOM
Leonid Startseve721ebe2021-10-29 14:41:49 +0300163 if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark" || project.name == "guide") return
164
165 // Animalsniffer setup
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +0300166 apply plugin: 'ru.vyarus.animalsniffer'
167
168 afterEvaluate { // Can be applied only when the project is evaluated
169 animalsniffer {
170 sourceSets = [sourceSets.main]
171 }
172 dependencies {
173 signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature'
174 signature 'org.codehaus.mojo.signature:java18:1.0@signature'
175 }
176 }
Leonid Startseve721ebe2021-10-29 14:41:49 +0300177
178 // Kover setup
179 apply from: rootProject.file("gradle/kover.gradle")
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +0300180}
181
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +0300182apply from: rootProject.file('gradle/compiler-version.gradle')
Leonid Startsevbc9c8f42020-04-06 22:30:25 +0300183apply from: rootProject.file("gradle/dokka.gradle")
Leonid Startsev98ead982021-06-28 13:02:07 +0300184apply from: rootProject.file("gradle/benchmark-parsing.gradle")