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" } |
| 17 | maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" } |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 18 | maven { url "https://plugins.gradle.org/m2/" } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 19 | } |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 20 | 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 Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 32 | dependencies { |
| 33 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 34 | classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 35 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" |
| 36 | classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version" |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 37 | classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version" |
| 38 | classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 39 | |
| 40 | // JMH plugins |
| 41 | classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2" |
| 42 | classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.7" |
| 43 | classpath "net.ltgt.gradle:gradle-apt-plugin:0.10" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 47 | allprojects { |
| 48 | def deployVersion = properties['DeployVersion'] |
| 49 | if (deployVersion != null) version = deployVersion |
| 50 | if (useKotlinSnapshot) { |
| 51 | kotlin_version = '1.2-SNAPSHOT' |
| 52 | } |
Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 53 | |
| 54 | repositories { |
| 55 | jcenter() |
| 56 | maven { url "https://kotlin.bintray.com/kotlin-dev" } |
| 57 | maven { url "https://kotlin.bintray.com/kotlinx" } |
| 58 | } |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | |
Roman Elizarov | 38b6fd3 | 2018-01-17 10:12:23 +0300 | [diff] [blame] | 62 | // Report Kotlin compiler version when building project |
| 63 | println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION") |
| 64 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 65 | // --------------- Configure sub-projects with Kotlin sources --------------- |
| 66 | |
| 67 | def sourceless = ['site'] |
| 68 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 69 | static def platformOf(project) { |
| 70 | if (project.name.endsWith("-common")) return "common" |
| 71 | if (project.name.endsWith("-js")) return "js" |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 72 | if (project.name.endsWith("-native")) return "native" |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 73 | return "jvm" |
| 74 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 75 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 76 | static def platformLib(base, platform) { |
| 77 | if (platform == "jvm") return base |
| 78 | return "$base-$platform" |
| 79 | } |
| 80 | |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 81 | subprojects { |
| 82 | if (useKotlinSnapshot) { |
| 83 | repositories { |
| 84 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 85 | } |
| 86 | } |
| 87 | configurations.all { |
| 88 | resolutionStrategy { |
| 89 | eachDependency { DependencyResolveDetails details -> |
| 90 | if (details.requested.group == 'org.jetbrains.kotlin') { |
| 91 | details.useVersion kotlin_version |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 98 | configure(subprojects.findAll { !sourceless.contains(it.name) }) { |
| 99 | def platform = platformOf(it) |
Roman Elizarov | e1a5652 | 2018-04-04 10:31:08 +0300 | [diff] [blame] | 100 | apply from: rootProject.file("gradle/compile-${platform}.gradle") |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | // --------------- Configure sub-projects that are part of the library --------------- |
| 104 | |
Vsevolod Tolstopyatov | 74bcc92 | 2018-05-03 20:07:54 +0300 | [diff] [blame] | 105 | def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'binary-compatibility-validator'] |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 106 | |
Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 107 | // Reconfigure source sets to avoid long "src/main/kotlin/fqn" |
| 108 | configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) { |
Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 109 | def projectName = it.name |
Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 110 | sourceSets { |
Roman Elizarov | f9408f6 | 2018-06-29 20:12:52 +0300 | [diff] [blame] | 111 | main.kotlin.srcDirs = ['src'] |
| 112 | test.kotlin.srcDirs = ['test'] |
Roman Elizarov | 7587eba | 2018-07-25 12:22:46 +0300 | [diff] [blame] | 113 | // todo: do we still need this workaround? |
Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 114 | if (!projectName.endsWith("-native")) { |
| 115 | main.resources.srcDirs = ['resources'] |
Roman Elizarov | 7587eba | 2018-07-25 12:22:46 +0300 | [diff] [blame] | 116 | test.resources.srcDirs = ['test-resources'] |
Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 117 | } |
Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 121 | // configure atomicfu |
| 122 | configure(subprojects.findAll { !internal.contains(it.name) }) { |
| 123 | def platform = platformOf(it) |
| 124 | apply from: rootProject.file("gradle/atomicfu-${platform}.gradle") |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 125 | } |
| 126 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 127 | // configure dependencies on core |
| 128 | configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) { |
| 129 | def platform = platformOf(it) |
| 130 | def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
| 131 | |
| 132 | if (it.name == coroutines_core) { |
| 133 | dependencies { |
| 134 | expectedBy project(':kotlinx-coroutines-core-common') |
| 135 | } |
| 136 | } else { |
| 137 | dependencies { |
| 138 | compile project(":$coroutines_core") |
| 139 | //the only way IDEA can resolve test classes |
| 140 | testCompile project(":$coroutines_core").sourceSets.test.output |
| 141 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | |
| 145 | // --------------- Configure sub-projects that are published --------------- |
| 146 | |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 147 | // todo: native is not published yet |
Vsevolod Tolstopyatov | 4ddfc91 | 2018-07-12 18:36:02 +0300 | [diff] [blame] | 148 | def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js'] |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 149 | |
| 150 | def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/" |
| 151 | def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list" |
| 152 | |
| 153 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 154 | apply from: rootProject.file('gradle/dokka.gradle') |
| 155 | apply from: rootProject.file('gradle/publish-bintray.gradle') |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 156 | } |
| 157 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 158 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 159 | def platform = platformOf(it) |
| 160 | def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
| 161 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 162 | if (it.name != coroutines_core) { |
| 163 | dokka.dependsOn project(":$coroutines_core").dokka |
| 164 | |
| 165 | tasks.withType(dokka.getClass()) { |
| 166 | externalDocumentationLink { |
| 167 | url = new URL(core_docs_url) |
| 168 | packageListUrl = new URL("file://$core_docs_file") |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 173 | if (platform == "jvm") { |
| 174 | dokkaJavadoc.dependsOn project(":$coroutines_core").dokka |
Roman Elizarov | aa100ea | 2018-08-22 11:21:53 +0300 | [diff] [blame] | 175 | // dump declarations from main JVM module for binary-compatibility-validator |
| 176 | compileKotlin { |
Vsevolod Tolstopyatov | 74bcc92 | 2018-05-03 20:07:54 +0300 | [diff] [blame] | 177 | kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"] |
| 178 | } |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 179 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 180 | } |
| 181 | |
Roman Elizarov | 94fb2a3 | 2018-03-05 17:32:59 +0300 | [diff] [blame] | 182 | // main deployment task |
| 183 | task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true)) |
| 184 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 185 | apply plugin: 'base' |
| 186 | |
| 187 | clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } |