| Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | 
 | 3 |  */ | 
 | 4 |  | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 5 | buildscript { | 
| Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 6 |     ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null | 
 | 7 |     if (useKotlinSnapshot) { | 
| Roman Elizarov | dadd50c | 2017-12-21 17:34:12 +0300 | [diff] [blame] | 8 |         ext.kotlin_version = '1.2-SNAPSHOT' | 
| Roman Elizarov | 1f6b44d | 2017-10-26 17:51:52 +0300 | [diff] [blame] | 9 |         repositories { | 
 | 10 |             maven { url "https://oss.sonatype.org/content/repositories/snapshots" } | 
 | 11 |         } | 
 | 12 |     } | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 13 |     repositories { | 
 | 14 |         jcenter() | 
| Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 15 |         maven { url "https://kotlin.bintray.com/kotlinx" } | 
 | 16 |         maven { url "https://kotlin.bintray.com/kotlin-dev" } | 
| Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame] | 17 |         maven { url "https://kotlin.bintray.com/kotlin-eap" } | 
| Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 18 |         maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" } | 
| Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 19 |         maven { url "https://plugins.gradle.org/m2/" } | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 20 |     } | 
| Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 21 |     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 Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 33 |     dependencies { | 
| Vsevolod Tolstopyatov | 3179683 | 2018-11-12 14:49:41 +0300 | [diff] [blame] | 34 |         classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$artifactory_plugin_version" | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 35 |         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | 
| Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 36 |         classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version" | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 37 |         classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" | 
 | 38 |         classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version" | 
| Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 39 |         classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version" | 
 | 40 |         classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" | 
| Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 41 |  | 
 | 42 |         // JMH plugins | 
 | 43 |         classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2" | 
 | 44 |         classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.7" | 
 | 45 |         classpath "net.ltgt.gradle:gradle-apt-plugin:0.10" | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 46 |     } | 
 | 47 | } | 
 | 48 |  | 
| Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 49 | allprojects { | 
 | 50 |     def deployVersion = properties['DeployVersion'] | 
 | 51 |     if (deployVersion != null) version = deployVersion | 
 | 52 |     if (useKotlinSnapshot) { | 
 | 53 |         kotlin_version = '1.2-SNAPSHOT' | 
 | 54 |     } | 
| Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 55 |  | 
| Vsevolod Tolstopyatov | 6f01c93 | 2018-10-23 19:40:48 +0300 | [diff] [blame] | 56 |     def name = it.name | 
| Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 57 |     repositories { | 
| Vsevolod Tolstopyatov | 6f01c93 | 2018-10-23 19:40:48 +0300 | [diff] [blame] | 58 |         /* | 
 | 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 Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 65 |         jcenter() | 
| Vsevolod Tolstopyatov | 8a45c47 | 2018-10-24 11:55:30 +0300 | [diff] [blame] | 66 |         maven { url "https://kotlin.bintray.com/kotlin-dev" } | 
| Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame] | 67 |         maven { url "https://kotlin.bintray.com/kotlin-eap" } | 
| Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 68 |         maven { url "https://kotlin.bintray.com/kotlinx" } | 
 | 69 |     } | 
| Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 70 | } | 
 | 71 |  | 
 | 72 |  | 
| Roman Elizarov | 38b6fd3 | 2018-01-17 10:12:23 +0300 | [diff] [blame] | 73 | // Report Kotlin compiler version when building project | 
 | 74 | println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION") | 
 | 75 |  | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 76 | // --------------- Configure sub-projects with Kotlin sources --------------- | 
 | 77 |  | 
 | 78 | def sourceless = ['site'] | 
 | 79 |  | 
| Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 80 | static def platformOf(project) { | 
 | 81 |     if (project.name.endsWith("-common")) return "common" | 
 | 82 |     if (project.name.endsWith("-js")) return "js" | 
| Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 83 |     if (project.name.endsWith("-native")) return "native" | 
| Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 84 |     return "jvm" | 
 | 85 | } | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 86 |  | 
| Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 87 | static def platformLib(base, platform) { | 
 | 88 |     if (platform == "jvm") return base | 
 | 89 |     return "$base-$platform" | 
 | 90 | } | 
 | 91 |  | 
| Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 92 | subprojects { | 
 | 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 Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 109 | configure(subprojects.findAll { !sourceless.contains(it.name)  }) { | 
 | 110 |     def platform = platformOf(it) | 
| Roman Elizarov | e1a5652 | 2018-04-04 10:31:08 +0300 | [diff] [blame] | 111 |     apply from: rootProject.file("gradle/compile-${platform}.gradle") | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 112 | } | 
 | 113 |  | 
 | 114 | // --------------- Configure sub-projects that are part of the library --------------- | 
 | 115 |  | 
| Vsevolod Tolstopyatov | 706e393 | 2018-10-13 15:40:32 +0300 | [diff] [blame] | 116 | def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'stdlib-stubs', 'binary-compatibility-validator'] | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 117 |  | 
| Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 118 | // Reconfigure source sets to avoid long "src/main/kotlin/fqn" | 
 | 119 | configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) { | 
| Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 120 |     def projectName = it.name | 
| Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 121 |     sourceSets { | 
| Roman Elizarov | f9408f6 | 2018-06-29 20:12:52 +0300 | [diff] [blame] | 122 |         main.kotlin.srcDirs = ['src'] | 
 | 123 |         test.kotlin.srcDirs = ['test'] | 
| Roman Elizarov | 7587eba | 2018-07-25 12:22:46 +0300 | [diff] [blame] | 124 |         // todo: do we still need this workaround? | 
| Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 125 |         if (!projectName.endsWith("-native")) { | 
 | 126 |             main.resources.srcDirs = ['resources'] | 
| Roman Elizarov | 7587eba | 2018-07-25 12:22:46 +0300 | [diff] [blame] | 127 |             test.resources.srcDirs = ['test-resources'] | 
| Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 128 |         } | 
| Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 129 |     } | 
 | 130 | } | 
 | 131 |  | 
| Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 132 | // configure atomicfu | 
 | 133 | configure(subprojects.findAll { !internal.contains(it.name) }) { | 
 | 134 |     def platform = platformOf(it) | 
 | 135 |     apply from: rootProject.file("gradle/atomicfu-${platform}.gradle") | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 136 | } | 
 | 137 |  | 
| Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 138 | // configure dependencies on core | 
 | 139 | configure(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 Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 153 |     } | 
 | 154 | } | 
 | 155 |  | 
 | 156 | // --------------- Configure sub-projects that are published --------------- | 
 | 157 |  | 
| Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 158 | // todo: native is not published yet | 
| Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 159 | def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js'] | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 160 |  | 
 | 161 | def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/" | 
 | 162 | def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list" | 
 | 163 |  | 
 | 164 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { | 
| Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 165 |     apply from: rootProject.file('gradle/dokka.gradle') | 
 | 166 |     apply from: rootProject.file('gradle/publish-bintray.gradle') | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 167 | } | 
 | 168 |  | 
| Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 169 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { | 
| Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 170 |     def platform = platformOf(it) | 
 | 171 |     def coroutines_core = platformLib("kotlinx-coroutines-core", platform) | 
 | 172 |  | 
| Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 173 |     if (it.name != coroutines_core) { | 
 | 174 |         dokka.dependsOn project(":$coroutines_core").dokka | 
 | 175 |  | 
 | 176 |         tasks.withType(dokka.getClass()) { | 
 | 177 |             externalDocumentationLink { | 
 | 178 |                 url = new URL(core_docs_url) | 
 | 179 |                 packageListUrl = new URL("file://$core_docs_file") | 
 | 180 |             } | 
 | 181 |         } | 
 | 182 |     } | 
| Vsevolod Tolstopyatov | e6e8239 | 2018-10-09 19:06:29 +0300 | [diff] [blame] | 183 |  | 
| Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 184 |     if (platform == "jvm") { | 
 | 185 |         dokkaJavadoc.dependsOn project(":$coroutines_core").dokka | 
| Roman Elizarov | aa100ea | 2018-08-22 11:21:53 +0300 | [diff] [blame] | 186 |         // dump declarations from main JVM module for binary-compatibility-validator | 
 | 187 |         compileKotlin { | 
| Vsevolod Tolstopyatov | 74bcc92 | 2018-05-03 20:07:54 +0300 | [diff] [blame] | 188 |             kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"] | 
 | 189 |         } | 
| Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 190 |     } | 
| Vsevolod Tolstopyatov | e6e8239 | 2018-10-09 19:06:29 +0300 | [diff] [blame] | 191 |  | 
 | 192 |  | 
 | 193 |     tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { | 
 | 194 |         kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental", | 
 | 195 |                                            "-Xuse-experimental=kotlin.experimental.ExperimentalTypeInference", | 
| Vsevolod Tolstopyatov | 06600a2 | 2018-11-13 13:47:27 +0300 | [diff] [blame^] | 196 |                                            "-Xuse-experimental=kotlin.ExperimentalMultiplatform", | 
| Vsevolod Tolstopyatov | e6e8239 | 2018-10-09 19:06:29 +0300 | [diff] [blame] | 197 |                                            "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", | 
 | 198 |                                            "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi", | 
| Vsevolod Tolstopyatov | d88e427 | 2018-11-27 14:19:31 +0300 | [diff] [blame] | 199 |                                            "-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi", | 
 | 200 |                                            "-progressive"] | 
| Vsevolod Tolstopyatov | e6e8239 | 2018-10-09 19:06:29 +0300 | [diff] [blame] | 201 |     } | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 202 | } | 
 | 203 |  | 
| Roman Elizarov | 94fb2a3 | 2018-03-05 17:32:59 +0300 | [diff] [blame] | 204 | // main deployment task | 
 | 205 | task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true)) | 
 | 206 |  | 
| Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 207 | apply plugin: 'base' | 
 | 208 |  | 
 | 209 | clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } |