blob: ddc65a5d6c5f0c0f55a650ffb50980e12d627ee9 [file] [log] [blame]
Kirill Timofeeva5186962017-10-25 14:25:47 +03001buildscript {
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +03002 ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null
3 if (useKotlinSnapshot) {
Roman Elizarovdadd50c2017-12-21 17:34:12 +03004 ext.kotlin_version = '1.2-SNAPSHOT'
Roman Elizarov1f6b44d2017-10-26 17:51:52 +03005 repositories {
6 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
7 }
8 }
Kirill Timofeeva5186962017-10-25 14:25:47 +03009 repositories {
10 jcenter()
Roman Elizarov31452902018-04-11 13:58:19 +030011 maven { url "https://kotlin.bintray.com/kotlinx" }
12 maven { url "https://kotlin.bintray.com/kotlin-dev" }
13 maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" }
Roman Elizarov65eff0b2017-12-20 15:51:31 +030014 maven { url "https://plugins.gradle.org/m2/" }
Kirill Timofeeva5186962017-10-25 14:25:47 +030015 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030016 configurations.classpath {
17 resolutionStrategy {
18 eachDependency { DependencyResolveDetails details ->
19 if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name != 'kotlin-native-gradle-plugin') {
20 // fix version of all dependencies from org.jetbrains.kotlin group
21 // even when other dependencies require other versions indirectly,
22 // except kotlin-native, which has its own pre-release versioning
23 details.useVersion kotlin_version
24 }
25 }
26 }
27 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030028 dependencies {
29 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Roman Elizarov31452902018-04-11 13:58:19 +030030 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030031 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
32 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
Roman Elizarov65eff0b2017-12-20 15:51:31 +030033 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
34 classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030035 }
36}
37
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030038allprojects {
39 def deployVersion = properties['DeployVersion']
40 if (deployVersion != null) version = deployVersion
41 if (useKotlinSnapshot) {
42 kotlin_version = '1.2-SNAPSHOT'
43 }
44}
45
46
Roman Elizarov38b6fd32018-01-17 10:12:23 +030047// Report Kotlin compiler version when building project
48println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
49
Kirill Timofeeva5186962017-10-25 14:25:47 +030050// --------------- Configure sub-projects with Kotlin sources ---------------
51
52def sourceless = ['site']
53
Roman Elizarove1c0b652017-12-01 14:02:57 +030054static def platformOf(project) {
55 if (project.name.endsWith("-common")) return "common"
56 if (project.name.endsWith("-js")) return "js"
Roman Elizarov31452902018-04-11 13:58:19 +030057 if (project.name.endsWith("-native")) return "native"
Roman Elizarove1c0b652017-12-01 14:02:57 +030058 return "jvm"
59}
Kirill Timofeeva5186962017-10-25 14:25:47 +030060
Roman Elizarove1c0b652017-12-01 14:02:57 +030061static def platformLib(base, platform) {
62 if (platform == "jvm") return base
63 return "$base-$platform"
64}
65
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030066subprojects {
67 if (useKotlinSnapshot) {
68 repositories {
69 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
70 }
71 }
72 configurations.all {
73 resolutionStrategy {
74 eachDependency { DependencyResolveDetails details ->
75 if (details.requested.group == 'org.jetbrains.kotlin') {
76 details.useVersion kotlin_version
77 }
78 }
79 }
80 }
81}
82
Roman Elizarove1c0b652017-12-01 14:02:57 +030083configure(subprojects.findAll { !sourceless.contains(it.name) }) {
84 def platform = platformOf(it)
Roman Elizarove1a56522018-04-04 10:31:08 +030085 apply from: rootProject.file("gradle/compile-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +030086}
87
88// --------------- Configure sub-projects that are part of the library ---------------
89
Roman Elizarova9647992017-12-26 13:09:43 +030090def internal = sourceless + ['benchmarks', 'knit', 'js-stub']
Kirill Timofeeva5186962017-10-25 14:25:47 +030091
Roman Elizarov31452902018-04-11 13:58:19 +030092// configure atomicfu
93configure(subprojects.findAll { !internal.contains(it.name) }) {
94 def platform = platformOf(it)
95 apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +030096}
97
Roman Elizarove1c0b652017-12-01 14:02:57 +030098// configure dependencies on core
99configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
100 def platform = platformOf(it)
101 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
102
103 if (it.name == coroutines_core) {
104 dependencies {
105 expectedBy project(':kotlinx-coroutines-core-common')
106 }
107 } else {
108 dependencies {
109 compile project(":$coroutines_core")
110 //the only way IDEA can resolve test classes
111 testCompile project(":$coroutines_core").sourceSets.test.output
112 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300113 }
114}
115
116// --------------- Configure sub-projects that are published ---------------
117
Roman Elizarov31452902018-04-11 13:58:19 +0300118// todo: native is not published yet
119def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'kotlinx-coroutines-core-native']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300120
121def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
122def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
123
124configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300125 apply from: rootProject.file('gradle/dokka.gradle')
126 apply from: rootProject.file('gradle/publish-bintray.gradle')
Kirill Timofeeva5186962017-10-25 14:25:47 +0300127}
128
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300129configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300130 def platform = platformOf(it)
131 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
132
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300133 if (it.name != coroutines_core) {
134 dokka.dependsOn project(":$coroutines_core").dokka
135
136 tasks.withType(dokka.getClass()) {
137 externalDocumentationLink {
138 url = new URL(core_docs_url)
139 packageListUrl = new URL("file://$core_docs_file")
140 }
141 }
142 }
143
Roman Elizarove1c0b652017-12-01 14:02:57 +0300144 if (platform == "jvm") {
145 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
146 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300147}
148
Roman Elizarov94fb2a32018-03-05 17:32:59 +0300149// main deployment task
150task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
151
Kirill Timofeeva5186962017-10-25 14:25:47 +0300152apply plugin: 'base'
153
154clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }