blob: 07e6637ac56728afbe2e7455374432f26419e795 [file] [log] [blame]
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03001/*
2 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
Kirill Timofeeva5186962017-10-25 14:25:47 +03005buildscript {
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +03006 ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null
7 if (useKotlinSnapshot) {
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 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030020 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 Timofeeva5186962017-10-25 14:25:47 +030032 dependencies {
33 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Roman Elizarov31452902018-04-11 13:58:19 +030034 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030035 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
36 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
Roman Elizarov65eff0b2017-12-20 15:51:31 +030037 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
38 classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030039 }
40}
41
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030042allprojects {
43 def deployVersion = properties['DeployVersion']
44 if (deployVersion != null) version = deployVersion
45 if (useKotlinSnapshot) {
46 kotlin_version = '1.2-SNAPSHOT'
47 }
Roman Elizarov18fa1162018-06-27 15:13:01 +030048
49 repositories {
50 jcenter()
51 maven { url "https://kotlin.bintray.com/kotlin-dev" }
52 maven { url "https://kotlin.bintray.com/kotlinx" }
53 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030054}
55
56
Roman Elizarov38b6fd32018-01-17 10:12:23 +030057// Report Kotlin compiler version when building project
58println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
59
Kirill Timofeeva5186962017-10-25 14:25:47 +030060// --------------- Configure sub-projects with Kotlin sources ---------------
61
62def sourceless = ['site']
63
Roman Elizarove1c0b652017-12-01 14:02:57 +030064static def platformOf(project) {
65 if (project.name.endsWith("-common")) return "common"
66 if (project.name.endsWith("-js")) return "js"
Roman Elizarov31452902018-04-11 13:58:19 +030067 if (project.name.endsWith("-native")) return "native"
Roman Elizarove1c0b652017-12-01 14:02:57 +030068 return "jvm"
69}
Kirill Timofeeva5186962017-10-25 14:25:47 +030070
Roman Elizarove1c0b652017-12-01 14:02:57 +030071static def platformLib(base, platform) {
72 if (platform == "jvm") return base
73 return "$base-$platform"
74}
75
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030076subprojects {
77 if (useKotlinSnapshot) {
78 repositories {
79 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
80 }
81 }
82 configurations.all {
83 resolutionStrategy {
84 eachDependency { DependencyResolveDetails details ->
85 if (details.requested.group == 'org.jetbrains.kotlin') {
86 details.useVersion kotlin_version
87 }
88 }
89 }
90 }
91}
92
Roman Elizarove1c0b652017-12-01 14:02:57 +030093configure(subprojects.findAll { !sourceless.contains(it.name) }) {
94 def platform = platformOf(it)
Roman Elizarove1a56522018-04-04 10:31:08 +030095 apply from: rootProject.file("gradle/compile-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +030096}
97
98// --------------- Configure sub-projects that are part of the library ---------------
99
Vsevolod Tolstopyatov74bcc922018-05-03 20:07:54 +0300100def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'binary-compatibility-validator']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300101
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300102// Reconfigure source sets to avoid long "src/main/kotlin/fqn"
103configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) {
104 sourceSets {
Roman Elizarovf9408f62018-06-29 20:12:52 +0300105 main.kotlin.srcDirs = ['src']
106 test.kotlin.srcDirs = ['test']
107 main.resources.srcDirs = ['resources']
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300108 }
109}
110
Roman Elizarov31452902018-04-11 13:58:19 +0300111// configure atomicfu
112configure(subprojects.findAll { !internal.contains(it.name) }) {
113 def platform = platformOf(it)
114 apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +0300115}
116
Roman Elizarove1c0b652017-12-01 14:02:57 +0300117// configure dependencies on core
118configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
119 def platform = platformOf(it)
120 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
121
122 if (it.name == coroutines_core) {
123 dependencies {
124 expectedBy project(':kotlinx-coroutines-core-common')
125 }
126 } else {
127 dependencies {
128 compile project(":$coroutines_core")
129 //the only way IDEA can resolve test classes
130 testCompile project(":$coroutines_core").sourceSets.test.output
131 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300132 }
133}
134
135// --------------- Configure sub-projects that are published ---------------
136
Roman Elizarov31452902018-04-11 13:58:19 +0300137// todo: native is not published yet
138def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'kotlinx-coroutines-core-native']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300139
140def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
141def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
142
143configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300144 apply from: rootProject.file('gradle/dokka.gradle')
145 apply from: rootProject.file('gradle/publish-bintray.gradle')
Kirill Timofeeva5186962017-10-25 14:25:47 +0300146}
147
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300148configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300149 def platform = platformOf(it)
150 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
151
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300152 if (it.name != coroutines_core) {
153 dokka.dependsOn project(":$coroutines_core").dokka
154
155 tasks.withType(dokka.getClass()) {
156 externalDocumentationLink {
157 url = new URL(core_docs_url)
158 packageListUrl = new URL("file://$core_docs_file")
159 }
160 }
161 }
162
Roman Elizarove1c0b652017-12-01 14:02:57 +0300163 if (platform == "jvm") {
164 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
Vsevolod Tolstopyatov74bcc922018-05-03 20:07:54 +0300165
166 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
167 kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
168 }
169
Roman Elizarove1c0b652017-12-01 14:02:57 +0300170 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300171}
172
Roman Elizarov94fb2a32018-03-05 17:32:59 +0300173// main deployment task
174task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
175
Kirill Timofeeva5186962017-10-25 14:25:47 +0300176apply plugin: 'base'
177
178clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }