blob: 6d89b4705f3bb7ba7678ab4edf893effcb5eeed7 [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 Startsevb0fd1202018-12-12 19:42:48 +030015 ext.experimentalsEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030016 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
Vsevolod Tolstopyatov0d830ae2019-09-09 20:06:42 +030017 "-Xuse-experimental=kotlinx.serialization.InternalSerializationApi"
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030018 ]
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030019
Leonid Startsevb0fd1202018-12-12 19:42:48 +030020 ext.experimentalsInTestEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030021 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
Vsevolod Tolstopyatov419ddb92020-08-11 05:08:17 -070022 "-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi",
Roman Elizarov5459c102020-08-11 12:27:36 +030023 "-Xuse-experimental=kotlinx.serialization.InternalSerializationApi",
24 "-Xuse-experimental=kotlin.ExperimentalUnsignedTypes"
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030025 ]
Leonid Startsev08d3ca02017-07-26 15:16:23 +030026
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030027 /*
Leonid Startsevcea9b432019-11-19 14:14:26 +030028 * This property group is used to build kotlinx.serialization against Kotlin compiler snapshot.
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030029 * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version.
30 * DO NOT change the name of these properties without adapting kotlinx.train build chain.
31 */
32 def prop = rootProject.properties['build_snapshot_train']
33 ext.build_snapshot_train = prop != null && prop != ""
34 if (build_snapshot_train) {
35 ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
36 if (kotlin_version == null) {
37 throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
38 }
39 repositories {
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030040 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030041 }
42 }
43
Leonid Startsev08d3ca02017-07-26 15:16:23 +030044 repositories {
Leonid Startsev6fbc2152017-09-21 16:18:32 +030045 mavenLocal()
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 Startsev08d3ca02017-07-26 15:16:23 +030053 }
54
Leonid Startsevd656e5a2019-06-14 12:06:23 +030055 configurations.classpath {
56 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
57 if (details.requested.group == 'org.jetbrains.kotlin') {
58 details.useVersion kotlin_version
59 }
60 }
61 }
62
Leonid Startsev08d3ca02017-07-26 15:16:23 +030063 dependencies {
Leonid Startsev45aa7c72019-04-23 21:29:03 +030064 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
65 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030066 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070067 classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$validator_version"
Roman Elizarov5459c102020-08-11 12:27:36 +030068 classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +030069 classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.3' // Android API check
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030070
Leonid Startsev45aa7c72019-04-23 21:29:03 +030071 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
Leonid Startsevbae49f92018-05-03 19:57:01 +030072
Leonid Startsev45aa7c72019-04-23 21:29:03 +030073 // Various benchmarking stuff
74 classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
Mark Kosichkinc5672e92021-05-24 21:38:20 +030075 classpath "me.champeau.gradle:jmh-gradle-plugin:0.5.3"
Leonid Startsev45aa7c72019-04-23 21:29:03 +030076 classpath "net.ltgt.gradle:gradle-apt-plugin:0.21"
Leonid Startsev08d3ca02017-07-26 15:16:23 +030077 }
78}
79
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +030080// To make it visible for compiler-version.gradle
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030081ext.compilerVersion = org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION
Vsevolod Tolstopyatov07f730a2021-01-22 03:32:08 -080082ext.nativeDebugBuild = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +030083
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070084apply plugin: 'binary-compatibility-validator'
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +030085apply plugin: 'base'
86apply plugin: 'kotlinx-knit'
Leonid Startsev45aa7c72019-04-23 21:29:03 +030087
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070088apiValidation {
Roman Elizarov5459c102020-08-11 12:27:36 +030089 ignoredProjects += ["benchmark", "guide", "kotlinx-serialization"]
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070090}
Leonid Startsev00dd4f52017-08-23 16:09:21 +030091
Roman Elizarov5459c102020-08-11 12:27:36 +030092knit {
93 siteRoot = "https://kotlin.github.io/kotlinx.serialization"
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -070094 moduleDocs = "build/dokka/htmlMultiModule"
Roman Elizarov5459c102020-08-11 12:27:36 +030095}
96
97// Build API docs for all modules with dokka before running Knit
98knitPrepare.dependsOn "dokka"
99
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300100allprojects {
101 group 'org.jetbrains.kotlinx'
Leonid Startsev476b7222018-06-26 17:06:14 +0300102
Leonid Startsevf5accd12020-02-25 20:42:46 +0300103 def deployVersion = properties['DeployVersion']
104 if (deployVersion != null) version = deployVersion
Leonid Startsev78d5d2d2019-07-25 13:51:54 +0300105
Leonid Startsev476b7222018-06-26 17:06:14 +0300106 if (project.hasProperty("bootstrap")) {
107 version = version + '-SNAPSHOT'
108 }
Leonid Startsev84062e12017-09-25 16:41:38 +0300109
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300110 // the only place where HostManager could be instantiated
111 project.ext.hostManager = new org.jetbrains.kotlin.konan.target.HostManager()
112
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300113 if (build_snapshot_train) {
114 // Snapshot-specific
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300115 repositories {
116 mavenLocal()
117 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
118 }
119 }
Leonid Startsevcf1db5c2019-09-17 19:33:44 +0300120
121 configurations.all {
122 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
123 if (details.requested.group == 'org.jetbrains.kotlin') {
124 details.useVersion kotlin_version
125 }
126 }
127 }
128
Leonid Startsev84062e12017-09-25 16:41:38 +0300129 repositories {
Leonid Startsev6a8dc862021-02-04 17:03:31 +0300130 mavenCentral()
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -0700131 maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
Vsevolod Tolstopyatov6d2e5cf2021-03-17 15:00:40 +0300132 // kotlin-dev with space redirector
133 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
134 // For Dokka that depends on kotlinx-html
Leonid Startsev9f8d0502021-07-08 12:12:06 +0300135 maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" }
Vsevolod Tolstopyatov6d2e5cf2021-03-17 15:00:40 +0300136 // For local development
137 mavenLocal()
Leonid Startsev9f8d0502021-07-08 12:12:06 +0300138
Leonid Startsev84062e12017-09-25 16:41:38 +0300139 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300140}
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300141
Leonid Startsev1c35d912017-10-04 12:26:43 +0300142subprojects {
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300143 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
144 if (task.name.contains("Test") || task.name.contains("Jmh")) {
145 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
146 } else {
147 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
148 }
149 }
150
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300151 apply from: rootProject.file('gradle/teamcity.gradle')
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300152 // Configure publishing for some artifacts
Roman Elizarov5459c102020-08-11 12:27:36 +0300153 if (project.name != "benchmark" && project.name != "guide") {
154 apply from: rootProject.file('gradle/publishing.gradle')
155 }
156
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300157}
Leonid Startseved87fbd2017-08-04 17:33:09 +0300158
Vsevolod Tolstopyatovab5c1392021-06-09 15:38:57 +0300159subprojects {
160 // Can't be applied to BOM
161 if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark") return
162 apply plugin: 'ru.vyarus.animalsniffer'
163
164 afterEvaluate { // Can be applied only when the project is evaluated
165 animalsniffer {
166 sourceSets = [sourceSets.main]
167 }
168 dependencies {
169 signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature'
170 signature 'org.codehaus.mojo.signature:java18:1.0@signature'
171 }
172 }
173}
174
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +0300175apply from: rootProject.file('gradle/compiler-version.gradle')
Leonid Startsevbc9c8f42020-04-06 22:30:25 +0300176apply from: rootProject.file("gradle/dokka.gradle")
Leonid Startsev98ead982021-06-28 13:02:07 +0300177apply from: rootProject.file("gradle/benchmark-parsing.gradle")