blob: 32632ff7ad35e25fb3a70b9223bdd7464160d7a1 [file] [log] [blame]
Kirill Timofeeva5186962017-10-25 14:25:47 +03001allprojects {
Roman Elizarovba5e5da2017-10-27 14:02:55 +03002 def deployVersion = properties['DeployVersion']
3 if (deployVersion != null) version = deployVersion
Kirill Timofeeva5186962017-10-25 14:25:47 +03004}
5
6buildscript {
Roman Elizarov8fca5d32018-01-17 10:21:43 +03007 if (rootProject.properties['kotlinSnapshot'] != null) {
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 }
20 dependencies {
21 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Roman Elizarov31452902018-04-11 13:58:19 +030022 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030023 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
24 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
Roman Elizarov65eff0b2017-12-20 15:51:31 +030025 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
26 classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030027 }
28}
29
Roman Elizarov38b6fd32018-01-17 10:12:23 +030030// Report Kotlin compiler version when building project
31println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
32
Kirill Timofeeva5186962017-10-25 14:25:47 +030033// --------------- Configure sub-projects with Kotlin sources ---------------
34
35def sourceless = ['site']
36
Roman Elizarove1c0b652017-12-01 14:02:57 +030037static def platformOf(project) {
38 if (project.name.endsWith("-common")) return "common"
39 if (project.name.endsWith("-js")) return "js"
Roman Elizarov31452902018-04-11 13:58:19 +030040 if (project.name.endsWith("-native")) return "native"
Roman Elizarove1c0b652017-12-01 14:02:57 +030041 return "jvm"
42}
Kirill Timofeeva5186962017-10-25 14:25:47 +030043
Roman Elizarove1c0b652017-12-01 14:02:57 +030044static def platformLib(base, platform) {
45 if (platform == "jvm") return base
46 return "$base-$platform"
47}
48
49configure(subprojects.findAll { !sourceless.contains(it.name) }) {
50 def platform = platformOf(it)
Roman Elizarove1a56522018-04-04 10:31:08 +030051 apply from: rootProject.file("gradle/compile-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +030052}
53
54// --------------- Configure sub-projects that are part of the library ---------------
55
Roman Elizarova9647992017-12-26 13:09:43 +030056def internal = sourceless + ['benchmarks', 'knit', 'js-stub']
Kirill Timofeeva5186962017-10-25 14:25:47 +030057
Roman Elizarov31452902018-04-11 13:58:19 +030058// configure atomicfu
59configure(subprojects.findAll { !internal.contains(it.name) }) {
60 def platform = platformOf(it)
61 apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +030062}
63
Roman Elizarove1c0b652017-12-01 14:02:57 +030064// configure dependencies on core
65configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
66 def platform = platformOf(it)
67 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
68
69 if (it.name == coroutines_core) {
70 dependencies {
71 expectedBy project(':kotlinx-coroutines-core-common')
72 }
73 } else {
74 dependencies {
75 compile project(":$coroutines_core")
76 //the only way IDEA can resolve test classes
77 testCompile project(":$coroutines_core").sourceSets.test.output
78 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030079 }
80}
81
82// --------------- Configure sub-projects that are published ---------------
83
Roman Elizarov31452902018-04-11 13:58:19 +030084// todo: native is not published yet
85def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'kotlinx-coroutines-core-native']
Kirill Timofeeva5186962017-10-25 14:25:47 +030086
87def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
88def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
89
90configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +030091 apply from: rootProject.file('gradle/dokka.gradle')
92 apply from: rootProject.file('gradle/publish-bintray.gradle')
Kirill Timofeeva5186962017-10-25 14:25:47 +030093}
94
Roman Elizarov65eff0b2017-12-20 15:51:31 +030095configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +030096 def platform = platformOf(it)
97 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
98
Roman Elizarov65eff0b2017-12-20 15:51:31 +030099 if (it.name != coroutines_core) {
100 dokka.dependsOn project(":$coroutines_core").dokka
101
102 tasks.withType(dokka.getClass()) {
103 externalDocumentationLink {
104 url = new URL(core_docs_url)
105 packageListUrl = new URL("file://$core_docs_file")
106 }
107 }
108 }
109
Roman Elizarove1c0b652017-12-01 14:02:57 +0300110 if (platform == "jvm") {
111 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
112 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300113}
114
Roman Elizarov94fb2a32018-03-05 17:32:59 +0300115// main deployment task
116task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
117
Kirill Timofeeva5186962017-10-25 14:25:47 +0300118apply plugin: 'base'
119
120clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }