blob: 947a1a324f5c47d3038e9da837eb44b2a274b606 [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",
Roman Elizarov5459c102020-08-11 12:27:36 +030022 "-Xuse-experimental=kotlinx.serialization.InternalSerializationApi",
23 "-Xuse-experimental=kotlin.ExperimentalUnsignedTypes"
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030024 ]
Leonid Startsev08d3ca02017-07-26 15:16:23 +030025
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030026 /*
Leonid Startsevcea9b432019-11-19 14:14:26 +030027 * This property group is used to build kotlinx.serialization against Kotlin compiler snapshot.
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030028 * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version.
29 * DO NOT change the name of these properties without adapting kotlinx.train build chain.
30 */
31 def prop = rootProject.properties['build_snapshot_train']
32 ext.build_snapshot_train = prop != null && prop != ""
33 if (build_snapshot_train) {
34 ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
35 if (kotlin_version == null) {
36 throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
37 }
38 repositories {
39 mavenLocal()
40 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
41 maven { url "https://bintray.com/jetbrains/kotlin-native-dependencies" }
42 }
43 }
44
Leonid Startsev08d3ca02017-07-26 15:16:23 +030045 repositories {
Leonid Startsev6fbc2152017-09-21 16:18:32 +030046 mavenLocal()
Michael Kuzmin4b5cd432019-12-16 22:53:24 +030047 maven {
48 url "https://kotlin.bintray.com/kotlin-dev"
49 credentials {
50 username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') ?: ""
51 password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') ?: ""
52 }
53 }
Leonid Startsev45aa7c72019-04-23 21:29:03 +030054 maven { url 'https://kotlin.bintray.com/kotlin-eap' }
55 maven { url 'https://kotlin.bintray.com/kotlinx' }
Leonid Startsevbae49f92018-05-03 19:57:01 +030056 maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
Leonid Startsev97b71872019-02-05 13:04:43 +030057 jcenter()
Leonid Startsev45aa7c72019-04-23 21:29:03 +030058 gradlePluginPortal()
Leonid Startsev08d3ca02017-07-26 15:16:23 +030059 }
60
Leonid Startsevd656e5a2019-06-14 12:06:23 +030061 configurations.classpath {
62 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
63 if (details.requested.group == 'org.jetbrains.kotlin') {
64 details.useVersion kotlin_version
65 }
66 }
67 }
68
Leonid Startsev08d3ca02017-07-26 15:16:23 +030069 dependencies {
Leonid Startsev45aa7c72019-04-23 21:29:03 +030070 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
71 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030072 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070073 classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$validator_version"
Roman Elizarov5459c102020-08-11 12:27:36 +030074 classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
Leonid Startsevbc9c8f42020-04-06 22:30:25 +030075
Leonid Startsev45aa7c72019-04-23 21:29:03 +030076 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
Leonid Startsevbae49f92018-05-03 19:57:01 +030077
Leonid Startsev45aa7c72019-04-23 21:29:03 +030078 // Various benchmarking stuff
79 classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
80 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.8"
81 classpath "net.ltgt.gradle:gradle-apt-plugin:0.21"
Leonid Startsev08d3ca02017-07-26 15:16:23 +030082 }
83}
84
Leonid Startsev9f6d3b42019-10-09 18:07:41 +030085// To make it visible for compilerVersion.gradle
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +030086ext.compilerVersion = org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070087apply plugin: 'binary-compatibility-validator'
Leonid Startsev45aa7c72019-04-23 21:29:03 +030088
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070089apiValidation {
Roman Elizarov5459c102020-08-11 12:27:36 +030090 ignoredProjects += ["benchmark", "guide", "kotlinx-serialization"]
Vsevolod Tolstopyatov6de96482020-06-17 06:41:00 -070091}
Leonid Startsev00dd4f52017-08-23 16:09:21 +030092
Roman Elizarov5459c102020-08-11 12:27:36 +030093apply plugin: 'base'
94apply plugin: 'kotlinx-knit'
95
96knit {
97 siteRoot = "https://kotlin.github.io/kotlinx.serialization"
98}
99
100// Build API docs for all modules with dokka before running Knit
101knitPrepare.dependsOn "dokka"
102
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300103allprojects {
104 group 'org.jetbrains.kotlinx'
Leonid Startsev476b7222018-06-26 17:06:14 +0300105
Leonid Startsevf5accd12020-02-25 20:42:46 +0300106 def deployVersion = properties['DeployVersion']
107 if (deployVersion != null) version = deployVersion
Leonid Startsev78d5d2d2019-07-25 13:51:54 +0300108
Leonid Startsev476b7222018-06-26 17:06:14 +0300109 if (project.hasProperty("bootstrap")) {
110 version = version + '-SNAPSHOT'
111 }
Leonid Startsev84062e12017-09-25 16:41:38 +0300112
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300113 // the only place where HostManager could be instantiated
114 project.ext.hostManager = new org.jetbrains.kotlin.konan.target.HostManager()
115
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300116 if (build_snapshot_train) {
117 // Snapshot-specific
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300118 repositories {
119 mavenLocal()
120 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
121 }
122 }
Leonid Startsevcf1db5c2019-09-17 19:33:44 +0300123
124 configurations.all {
125 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
126 if (details.requested.group == 'org.jetbrains.kotlin') {
127 details.useVersion kotlin_version
128 }
129 }
130 }
131
Leonid Startsev84062e12017-09-25 16:41:38 +0300132 repositories {
Leonid Startsev84062e12017-09-25 16:41:38 +0300133 mavenLocal()
Leonid Startsev97b71872019-02-05 13:04:43 +0300134 jcenter()
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300135 maven { url "https://dl.bintray.com/kotlin/kotlinx" }
Michael Kuzmin4b5cd432019-12-16 22:53:24 +0300136 maven {
137 url "https://kotlin.bintray.com/kotlin-dev"
138 credentials {
139 username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') ?: ""
140 password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') ?: ""
141 }
142 }
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300143 maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
Leonid Startsev84062e12017-09-25 16:41:38 +0300144 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300145}
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300146
Leonid Startsev1c35d912017-10-04 12:26:43 +0300147subprojects {
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300148 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
149 if (task.name.contains("Test") || task.name.contains("Jmh")) {
150 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
151 } else {
152 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
153 }
154 }
155
Leonid Startsev9f6d3b42019-10-09 18:07:41 +0300156 apply from: rootProject.file('gradle/teamcity.gradle')
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300157 // Configure publishing for some artifacts
Roman Elizarov5459c102020-08-11 12:27:36 +0300158 if (project.name != "benchmark" && project.name != "guide") {
159 apply from: rootProject.file('gradle/publishing.gradle')
160 }
161
Leonid Startsev45aa7c72019-04-23 21:29:03 +0300162}
Leonid Startseved87fbd2017-08-04 17:33:09 +0300163
Vsevolod Tolstopyatovfa2231c2019-05-29 17:39:15 +0300164apply from: rootProject.file('gradle/compilerVersion.gradle')
Leonid Startsevbc9c8f42020-04-06 22:30:25 +0300165apply from: rootProject.file("gradle/dokka.gradle")