blob: 83346e98c48add42a004c3dd3300f09e46b9118b [file] [log] [blame]
Roman Elizarov26af9192017-09-21 18:12:04 +03001/*
Leonid Startsevbc9c8f42020-04-06 22:30:25 +03002 * Copyright 2017-2020 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 {
40 mavenLocal()
41 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
42 maven { url "https://bintray.com/jetbrains/kotlin-native-dependencies" }
43 }
44 }
Alexander Likhachev2e565422020-11-17 13:09:24 +030045 // These two flags are enabled in train builds for JVM IR compiler testing
46 ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
47 ext.jvm_ir_api_check_enabled = rootProject.properties['enable_jvm_ir_api_check'] != null
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030048
Leonid Startsev08d3ca02017-07-26 15:16:23 +030049 repositories {
Leonid Startsev6fbc2152017-09-21 16:18:32 +030050 mavenLocal()
Vsevolod Tolstopyatov6995ef12020-08-24 16:01:54 +030051 // Future replacement for kotlin-dev, with cache redirector
52 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
Michael Kuzmin4b5cd432019-12-16 22:53:24 +030053 maven {
54 url "https://kotlin.bintray.com/kotlin-dev"
55 credentials {
56 username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') ?: ""
57 password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') ?: ""
58 }
59 }
Leonid Startsev45aa7c72019-04-23 21:29:03 +030060 maven { url 'https://kotlin.bintray.com/kotlin-eap' }
61 maven { url 'https://kotlin.bintray.com/kotlinx' }
Leonid Startsevbae49f92018-05-03 19:57:01 +030062 maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -070063 maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
Leonid Startsev97b71872019-02-05 13:04:43 +030064 jcenter()
Leonid Startsev45aa7c72019-04-23 21:29:03 +030065 gradlePluginPortal()
Leonid Startsev08d3ca02017-07-26 15:16:23 +030066 }
67
Leonid Startsevd656e5a2019-06-14 12:06:23 +030068 configurations.classpath {
69 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
70 if (details.requested.group == 'org.jetbrains.kotlin') {
71 details.useVersion kotlin_version
72 }
73 }
74 }
75
Leonid Startsev08d3ca02017-07-26 15:16:23 +030076 dependencies {
Leonid Startsev45aa7c72019-04-23 21:29:03 +030077 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
78 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030079 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070080 classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$validator_version"
Roman Elizarov5459c102020-08-11 12:27:36 +030081 classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030082
Leonid Startsev45aa7c72019-04-23 21:29:03 +030083 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
Leonid Startsevbae49f92018-05-03 19:57:01 +030084
Leonid Startsev45aa7c72019-04-23 21:29:03 +030085 // Various benchmarking stuff
86 classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
87 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.8"
88 classpath "net.ltgt.gradle:gradle-apt-plugin:0.21"
Leonid Startsev08d3ca02017-07-26 15:16:23 +030089 }
90}
91
Vsevolod Tolstopyatov608cbad2020-09-14 15:38:02 +030092// To make it visible for compiler-version.gradle
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030093ext.compilerVersion = org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070094apply plugin: 'binary-compatibility-validator'
Leonid Startsev45aa7c72019-04-23 21:29:03 +030095
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070096apiValidation {
Roman Elizarov5459c102020-08-11 12:27:36 +030097 ignoredProjects += ["benchmark", "guide", "kotlinx-serialization"]
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070098}
Leonid Startsev00dd4f52017-08-23 16:09:21 +030099
Roman Elizarov5459c102020-08-11 12:27:36 +0300100apply plugin: 'base'
101apply plugin: 'kotlinx-knit'
102
103knit {
104 siteRoot = "https://kotlin.github.io/kotlinx.serialization"
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -0700105 moduleDocs = "build/dokka/htmlMultiModule"
Roman Elizarov5459c102020-08-11 12:27:36 +0300106}
107
108// Build API docs for all modules with dokka before running Knit
109knitPrepare.dependsOn "dokka"
110
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300111allprojects {
112 group 'org.jetbrains.kotlinx'
Leonid Startsev476b7222018-06-26 17:06:14 +0300113
Leonid Startsevf5accd12020-02-25 20:42:46 +0300114 def deployVersion = properties['DeployVersion']
115 if (deployVersion != null) version = deployVersion
Leonid Startsev78d5d2d2019-07-25 13:51:54 +0300116
Leonid Startsev476b7222018-06-26 17:06:14 +0300117 if (project.hasProperty("bootstrap")) {
118 version = version + '-SNAPSHOT'
119 }
Leonid Startsev84062e12017-09-25 16:41:38 +0300120
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300121 // the only place where HostManager could be instantiated
122 project.ext.hostManager = new org.jetbrains.kotlin.konan.target.HostManager()
123
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300124 if (build_snapshot_train) {
125 // Snapshot-specific
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300126 repositories {
127 mavenLocal()
128 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
129 }
130 }
Leonid Startsevcf1db5c2019-09-17 19:33:44 +0300131
132 configurations.all {
133 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
134 if (details.requested.group == 'org.jetbrains.kotlin') {
135 details.useVersion kotlin_version
136 }
137 }
138 }
139
Leonid Startsev84062e12017-09-25 16:41:38 +0300140 repositories {
Leonid Startsev84062e12017-09-25 16:41:38 +0300141 mavenLocal()
Leonid Startsev97b71872019-02-05 13:04:43 +0300142 jcenter()
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300143 maven { url "https://dl.bintray.com/kotlin/kotlinx" }
Vsevolod Tolstopyatov6995ef12020-08-24 16:01:54 +0300144 // Future replacement for kotlin-dev, with cache redirector
145 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
Michael Kuzmin4b5cd432019-12-16 22:53:24 +0300146 maven {
147 url "https://kotlin.bintray.com/kotlin-dev"
148 credentials {
149 username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') ?: ""
150 password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') ?: ""
151 }
152 }
Vsevolod Tolstopyatovd3d2dca2020-10-03 06:18:32 -0700153 maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300154 maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
Leonid Startsev84062e12017-09-25 16:41:38 +0300155 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300156}
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300157
Leonid Startsev1c35d912017-10-04 12:26:43 +0300158subprojects {
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300159 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
160 if (task.name.contains("Test") || task.name.contains("Jmh")) {
161 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
162 } else {
163 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
164 }
165 }
166
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300167 apply from: rootProject.file('gradle/teamcity.gradle')
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300168 // Configure publishing for some artifacts
Roman Elizarov5459c102020-08-11 12:27:36 +0300169 if (project.name != "benchmark" && project.name != "guide") {
170 apply from: rootProject.file('gradle/publishing.gradle')
171 }
172
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300173}
Leonid Startseved87fbd2017-08-04 17:33:09 +0300174
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")
Alexander Likhachev2e565422020-11-17 13:09:24 +0300177
178// Disable binary compatibility check for JVM IR compiler output by default
179if (jvm_ir_enabled) {
180 subprojects { project ->
181 afterEvaluate {
182 configure(tasks.matching { it.name == "apiCheck" }) {
183 enabled = enabled && jvm_ir_api_check_enabled
184 }
185 }
186 }
187}