blob: 116af20108bb87ce079f3bf8c452dde09adfad62 [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" }
17 maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" }
Roman Elizarov65eff0b2017-12-20 15:51:31 +030018 maven { url "https://plugins.gradle.org/m2/" }
Kirill Timofeeva5186962017-10-25 14:25:47 +030019 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030020 configurations.classpath {
21 resolutionStrategy {
22 eachDependency { DependencyResolveDetails details ->
23 if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name != 'kotlin-native-gradle-plugin') {
24 // fix version of all dependencies from org.jetbrains.kotlin group
25 // even when other dependencies require other versions indirectly,
26 // except kotlin-native, which has its own pre-release versioning
27 details.useVersion kotlin_version
28 }
29 }
30 }
31 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030032 dependencies {
33 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Roman Elizarov31452902018-04-11 13:58:19 +030034 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030035 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
36 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
Roman Elizarov65eff0b2017-12-20 15:51:31 +030037 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
38 classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030039 }
40}
41
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030042allprojects {
43 def deployVersion = properties['DeployVersion']
44 if (deployVersion != null) version = deployVersion
45 if (useKotlinSnapshot) {
46 kotlin_version = '1.2-SNAPSHOT'
47 }
Roman Elizarov18fa1162018-06-27 15:13:01 +030048
49 repositories {
50 jcenter()
51 maven { url "https://kotlin.bintray.com/kotlin-dev" }
52 maven { url "https://kotlin.bintray.com/kotlinx" }
53 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030054}
55
56
Roman Elizarov38b6fd32018-01-17 10:12:23 +030057// Report Kotlin compiler version when building project
58println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
59
Kirill Timofeeva5186962017-10-25 14:25:47 +030060// --------------- Configure sub-projects with Kotlin sources ---------------
61
62def sourceless = ['site']
63
Roman Elizarove1c0b652017-12-01 14:02:57 +030064static def platformOf(project) {
65 if (project.name.endsWith("-common")) return "common"
66 if (project.name.endsWith("-js")) return "js"
Roman Elizarov31452902018-04-11 13:58:19 +030067 if (project.name.endsWith("-native")) return "native"
Roman Elizarove1c0b652017-12-01 14:02:57 +030068 return "jvm"
69}
Kirill Timofeeva5186962017-10-25 14:25:47 +030070
Roman Elizarove1c0b652017-12-01 14:02:57 +030071static def platformLib(base, platform) {
72 if (platform == "jvm") return base
73 return "$base-$platform"
74}
75
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030076subprojects {
77 if (useKotlinSnapshot) {
78 repositories {
79 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
80 }
81 }
82 configurations.all {
83 resolutionStrategy {
84 eachDependency { DependencyResolveDetails details ->
85 if (details.requested.group == 'org.jetbrains.kotlin') {
86 details.useVersion kotlin_version
87 }
88 }
89 }
90 }
91}
92
Roman Elizarove1c0b652017-12-01 14:02:57 +030093configure(subprojects.findAll { !sourceless.contains(it.name) }) {
94 def platform = platformOf(it)
Roman Elizarove1a56522018-04-04 10:31:08 +030095 apply from: rootProject.file("gradle/compile-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +030096}
97
98// --------------- Configure sub-projects that are part of the library ---------------
99
Vsevolod Tolstopyatov74bcc922018-05-03 20:07:54 +0300100def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'binary-compatibility-validator']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300101
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300102// Reconfigure source sets to avoid long "src/main/kotlin/fqn"
103configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) {
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300104 def projectName = it.name
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300105 sourceSets {
Roman Elizarovf9408f62018-06-29 20:12:52 +0300106 main.kotlin.srcDirs = ['src']
107 test.kotlin.srcDirs = ['test']
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300108 if (!projectName.endsWith("-native")) {
109 main.resources.srcDirs = ['resources']
110 }
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300111 }
112}
113
Roman Elizarov31452902018-04-11 13:58:19 +0300114// configure atomicfu
115configure(subprojects.findAll { !internal.contains(it.name) }) {
116 def platform = platformOf(it)
117 apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +0300118}
119
Roman Elizarove1c0b652017-12-01 14:02:57 +0300120// configure dependencies on core
121configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
122 def platform = platformOf(it)
123 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
124
125 if (it.name == coroutines_core) {
126 dependencies {
127 expectedBy project(':kotlinx-coroutines-core-common')
128 }
129 } else {
130 dependencies {
131 compile project(":$coroutines_core")
132 //the only way IDEA can resolve test classes
133 testCompile project(":$coroutines_core").sourceSets.test.output
134 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300135 }
136}
137
138// --------------- Configure sub-projects that are published ---------------
139
Roman Elizarov31452902018-04-11 13:58:19 +0300140// todo: native is not published yet
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300141def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300142
143def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
144def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
145
146configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300147 apply from: rootProject.file('gradle/dokka.gradle')
148 apply from: rootProject.file('gradle/publish-bintray.gradle')
Kirill Timofeeva5186962017-10-25 14:25:47 +0300149}
150
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300151configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300152 def platform = platformOf(it)
153 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
154
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300155 if (it.name != coroutines_core) {
156 dokka.dependsOn project(":$coroutines_core").dokka
157
158 tasks.withType(dokka.getClass()) {
159 externalDocumentationLink {
160 url = new URL(core_docs_url)
161 packageListUrl = new URL("file://$core_docs_file")
162 }
163 }
164 }
165
Roman Elizarove1c0b652017-12-01 14:02:57 +0300166 if (platform == "jvm") {
167 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
Vsevolod Tolstopyatov74bcc922018-05-03 20:07:54 +0300168
169 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
170 kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
171 }
172
Roman Elizarove1c0b652017-12-01 14:02:57 +0300173 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300174}
175
Roman Elizarov94fb2a32018-03-05 17:32:59 +0300176// main deployment task
177task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
178
Kirill Timofeeva5186962017-10-25 14:25:47 +0300179apply plugin: 'base'
180
181clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }