Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 1 | buildscript { |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 2 | ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null |
| 3 | if (useKotlinSnapshot) { |
Roman Elizarov | dadd50c | 2017-12-21 17:34:12 +0300 | [diff] [blame] | 4 | ext.kotlin_version = '1.2-SNAPSHOT' |
Roman Elizarov | 1f6b44d | 2017-10-26 17:51:52 +0300 | [diff] [blame] | 5 | repositories { |
| 6 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 7 | } |
| 8 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 9 | repositories { |
| 10 | jcenter() |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 11 | 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 Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 14 | maven { url "https://plugins.gradle.org/m2/" } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 15 | } |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 16 | 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 Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 28 | dependencies { |
| 29 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 30 | classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 31 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" |
| 32 | classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version" |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 33 | classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version" |
| 34 | classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 35 | } |
| 36 | } |
| 37 | |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 38 | allprojects { |
| 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 Elizarov | 38b6fd3 | 2018-01-17 10:12:23 +0300 | [diff] [blame] | 47 | // Report Kotlin compiler version when building project |
| 48 | println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION") |
| 49 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 50 | // --------------- Configure sub-projects with Kotlin sources --------------- |
| 51 | |
| 52 | def sourceless = ['site'] |
| 53 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 54 | static def platformOf(project) { |
| 55 | if (project.name.endsWith("-common")) return "common" |
| 56 | if (project.name.endsWith("-js")) return "js" |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 57 | if (project.name.endsWith("-native")) return "native" |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 58 | return "jvm" |
| 59 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 60 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 61 | static def platformLib(base, platform) { |
| 62 | if (platform == "jvm") return base |
| 63 | return "$base-$platform" |
| 64 | } |
| 65 | |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 66 | subprojects { |
| 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 Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 83 | configure(subprojects.findAll { !sourceless.contains(it.name) }) { |
| 84 | def platform = platformOf(it) |
Roman Elizarov | e1a5652 | 2018-04-04 10:31:08 +0300 | [diff] [blame] | 85 | apply from: rootProject.file("gradle/compile-${platform}.gradle") |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | // --------------- Configure sub-projects that are part of the library --------------- |
| 89 | |
Roman Elizarov | a964799 | 2017-12-26 13:09:43 +0300 | [diff] [blame] | 90 | def internal = sourceless + ['benchmarks', 'knit', 'js-stub'] |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 91 | |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 92 | // configure atomicfu |
| 93 | configure(subprojects.findAll { !internal.contains(it.name) }) { |
| 94 | def platform = platformOf(it) |
| 95 | apply from: rootProject.file("gradle/atomicfu-${platform}.gradle") |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 96 | } |
| 97 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 98 | // configure dependencies on core |
| 99 | configure(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 Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 113 | } |
| 114 | } |
| 115 | |
| 116 | // --------------- Configure sub-projects that are published --------------- |
| 117 | |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 118 | // todo: native is not published yet |
| 119 | def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'kotlinx-coroutines-core-native'] |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 120 | |
| 121 | def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/" |
| 122 | def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list" |
| 123 | |
| 124 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 125 | apply from: rootProject.file('gradle/dokka.gradle') |
| 126 | apply from: rootProject.file('gradle/publish-bintray.gradle') |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 127 | } |
| 128 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 129 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 130 | def platform = platformOf(it) |
| 131 | def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
| 132 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 133 | 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 Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 144 | if (platform == "jvm") { |
| 145 | dokkaJavadoc.dependsOn project(":$coroutines_core").dokka |
| 146 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 147 | } |
| 148 | |
Roman Elizarov | 94fb2a3 | 2018-03-05 17:32:59 +0300 | [diff] [blame] | 149 | // main deployment task |
| 150 | task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true)) |
| 151 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 152 | apply plugin: 'base' |
| 153 | |
| 154 | clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } |