blob: c83fea97099143da94bd7d9296b745f5477c5a83 [file] [log] [blame]
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03001/*
2 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
Kirill Timofeeva5186962017-10-25 14:25:47 +03005buildscript {
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +03006 ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null
7 if (useKotlinSnapshot) {
Roman Elizarovdadd50c2017-12-21 17:34:12 +03008 ext.kotlin_version = '1.2-SNAPSHOT'
Roman Elizarov1f6b44d2017-10-26 17:51:52 +03009 repositories {
10 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
11 }
12 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030013 repositories {
14 jcenter()
Roman Elizarov31452902018-04-11 13:58:19 +030015 maven { url "https://kotlin.bintray.com/kotlinx" }
16 maven { url "https://kotlin.bintray.com/kotlin-dev" }
Roman Elizarov0950dfa2018-07-13 10:33:25 +030017 maven { url "https://kotlin.bintray.com/kotlin-eap" }
Roman Elizarov31452902018-04-11 13:58:19 +030018 maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" }
Roman Elizarov65eff0b2017-12-20 15:51:31 +030019 maven { url "https://plugins.gradle.org/m2/" }
Kirill Timofeeva5186962017-10-25 14:25:47 +030020 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030021 configurations.classpath {
22 resolutionStrategy {
23 eachDependency { DependencyResolveDetails details ->
24 if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name != 'kotlin-native-gradle-plugin') {
25 // fix version of all dependencies from org.jetbrains.kotlin group
26 // even when other dependencies require other versions indirectly,
27 // except kotlin-native, which has its own pre-release versioning
28 details.useVersion kotlin_version
29 }
30 }
31 }
32 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030033 dependencies {
Vsevolod Tolstopyatov31796832018-11-12 14:49:41 +030034 classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$artifactory_plugin_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030035 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Roman Elizarov31452902018-04-11 13:58:19 +030036 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030037 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
38 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
Roman Elizarov65eff0b2017-12-20 15:51:31 +030039 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
40 classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
Vsevolod Tolstopyatov305c66a2018-08-21 21:01:58 +030041
42 // JMH plugins
Vsevolod Tolstopyatov3781a822018-12-13 11:58:29 +030043 classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
Vsevolod Tolstopyatov305c66a2018-08-21 21:01:58 +030044 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.7"
45 classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
Kirill Timofeeva5186962017-10-25 14:25:47 +030046 }
47}
48
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030049allprojects {
50 def deployVersion = properties['DeployVersion']
51 if (deployVersion != null) version = deployVersion
52 if (useKotlinSnapshot) {
53 kotlin_version = '1.2-SNAPSHOT'
54 }
Roman Elizarov18fa1162018-06-27 15:13:01 +030055
Vsevolod Tolstopyatov6f01c932018-10-23 19:40:48 +030056 def name = it.name
Roman Elizarov18fa1162018-06-27 15:13:01 +030057 repositories {
Vsevolod Tolstopyatov6f01c932018-10-23 19:40:48 +030058 /*
59 * google should be first in the repository list because some of the play services
60 * transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution
61 */
62 if (name == "kotlinx-coroutines-play-services") {
63 google()
64 }
Roman Elizarov18fa1162018-06-27 15:13:01 +030065 jcenter()
Vsevolod Tolstopyatov8a45c472018-10-24 11:55:30 +030066 maven { url "https://kotlin.bintray.com/kotlin-dev" }
Roman Elizarov0950dfa2018-07-13 10:33:25 +030067 maven { url "https://kotlin.bintray.com/kotlin-eap" }
Roman Elizarov18fa1162018-06-27 15:13:01 +030068 maven { url "https://kotlin.bintray.com/kotlinx" }
69 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030070}
71
72
Roman Elizarov38b6fd32018-01-17 10:12:23 +030073// Report Kotlin compiler version when building project
74println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
75
Kirill Timofeeva5186962017-10-25 14:25:47 +030076// --------------- Configure sub-projects with Kotlin sources ---------------
77
78def sourceless = ['site']
79
Roman Elizarove1c0b652017-12-01 14:02:57 +030080static def platformOf(project) {
81 if (project.name.endsWith("-common")) return "common"
82 if (project.name.endsWith("-js")) return "js"
Roman Elizarov31452902018-04-11 13:58:19 +030083 if (project.name.endsWith("-native")) return "native"
Roman Elizarove1c0b652017-12-01 14:02:57 +030084 return "jvm"
85}
Kirill Timofeeva5186962017-10-25 14:25:47 +030086
Roman Elizarove1c0b652017-12-01 14:02:57 +030087static def platformLib(base, platform) {
88 if (platform == "jvm") return base
89 return "$base-$platform"
90}
91
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030092subprojects {
93 if (useKotlinSnapshot) {
94 repositories {
95 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
96 }
97 }
98 configurations.all {
99 resolutionStrategy {
100 eachDependency { DependencyResolveDetails details ->
101 if (details.requested.group == 'org.jetbrains.kotlin') {
102 details.useVersion kotlin_version
103 }
104 }
105 }
106 }
107}
108
Roman Elizarove1c0b652017-12-01 14:02:57 +0300109configure(subprojects.findAll { !sourceless.contains(it.name) }) {
110 def platform = platformOf(it)
Roman Elizarove1a56522018-04-04 10:31:08 +0300111 apply from: rootProject.file("gradle/compile-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +0300112}
113
114// --------------- Configure sub-projects that are part of the library ---------------
115
Vsevolod Tolstopyatov706e3932018-10-13 15:40:32 +0300116def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'stdlib-stubs', 'binary-compatibility-validator']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300117
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300118// Reconfigure source sets to avoid long "src/main/kotlin/fqn"
119configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) {
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300120 def projectName = it.name
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300121 sourceSets {
Roman Elizarovf9408f62018-06-29 20:12:52 +0300122 main.kotlin.srcDirs = ['src']
123 test.kotlin.srcDirs = ['test']
Roman Elizarov7587eba2018-07-25 12:22:46 +0300124 // todo: do we still need this workaround?
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300125 if (!projectName.endsWith("-native")) {
126 main.resources.srcDirs = ['resources']
Roman Elizarov7587eba2018-07-25 12:22:46 +0300127 test.resources.srcDirs = ['test-resources']
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300128 }
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300129 }
130}
131
Roman Elizarov31452902018-04-11 13:58:19 +0300132// configure atomicfu
133configure(subprojects.findAll { !internal.contains(it.name) }) {
134 def platform = platformOf(it)
135 apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +0300136}
137
Roman Elizarove1c0b652017-12-01 14:02:57 +0300138// configure dependencies on core
139configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
140 def platform = platformOf(it)
141 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
142
143 if (it.name == coroutines_core) {
144 dependencies {
145 expectedBy project(':kotlinx-coroutines-core-common')
146 }
147 } else {
148 dependencies {
149 compile project(":$coroutines_core")
150 //the only way IDEA can resolve test classes
151 testCompile project(":$coroutines_core").sourceSets.test.output
152 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300153 }
154}
155
156// --------------- Configure sub-projects that are published ---------------
157
Vsevolod Tolstopyatov4327b212018-12-17 19:49:12 +0300158def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'android-unit-tests']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300159
160def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
161def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
162
163configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300164 apply from: rootProject.file('gradle/dokka.gradle')
165 apply from: rootProject.file('gradle/publish-bintray.gradle')
Kirill Timofeeva5186962017-10-25 14:25:47 +0300166}
167
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300168configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300169 def platform = platformOf(it)
170 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
171
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300172 if (it.name != coroutines_core) {
173 dokka.dependsOn project(":$coroutines_core").dokka
174
175 tasks.withType(dokka.getClass()) {
176 externalDocumentationLink {
177 url = new URL(core_docs_url)
178 packageListUrl = new URL("file://$core_docs_file")
179 }
180 }
181 }
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300182
Roman Elizarove1c0b652017-12-01 14:02:57 +0300183 if (platform == "jvm") {
184 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
Roman Elizarovaa100ea2018-08-22 11:21:53 +0300185 // dump declarations from main JVM module for binary-compatibility-validator
186 compileKotlin {
Vsevolod Tolstopyatov74bcc922018-05-03 20:07:54 +0300187 kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
188 }
Roman Elizarove1c0b652017-12-01 14:02:57 +0300189 }
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300190
191
192 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
193 kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental",
194 "-Xuse-experimental=kotlin.experimental.ExperimentalTypeInference",
Vsevolod Tolstopyatov06600a22018-11-13 13:47:27 +0300195 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300196 "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
197 "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
Vsevolod Tolstopyatovd88e4272018-11-27 14:19:31 +0300198 "-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi",
199 "-progressive"]
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300200 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300201}
202
Roman Elizarov94fb2a32018-03-05 17:32:59 +0300203// main deployment task
204task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
205
Kirill Timofeeva5186962017-10-25 14:25:47 +0300206apply plugin: 'base'
207
208clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }