blob: 36ef722db4177ecca6d3ace542ea9d1b661cb693 [file] [log] [blame]
Kirill Timofeeva5186962017-10-25 14:25:47 +03001allprojects {
2 group = 'org.jetbrains.kotlinx'
Roman Elizarovba5e5da2017-10-27 14:02:55 +03003 def deployVersion = properties['DeployVersion']
4 if (deployVersion != null) version = deployVersion
Kirill Timofeeva5186962017-10-25 14:25:47 +03005}
6
7buildscript {
Roman Elizarov1f6b44d2017-10-26 17:51:52 +03008 if (System.properties['kotlinSnapshot'] != null) {
Roman Elizarovdadd50c2017-12-21 17:34:12 +03009 ext.kotlin_version = '1.2-SNAPSHOT'
Roman Elizarov1f6b44d2017-10-26 17:51:52 +030010 repositories {
11 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
12 }
13 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030014 repositories {
15 jcenter()
Roman Elizarov4d84a782017-11-30 13:23:40 +030016 maven { url "http://kotlin.bintray.com/kotlinx" }
Roman Elizarov65eff0b2017-12-20 15:51:31 +030017 maven { url "https://plugins.gradle.org/m2/" }
Kirill Timofeeva5186962017-10-25 14:25:47 +030018 }
19 dependencies {
20 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
21 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
22 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
Roman Elizarov65eff0b2017-12-20 15:51:31 +030023 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
24 classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030025 }
26}
27
28// --------------- pom configuration ---------------
29
30def pomConfig = {
31 licenses {
32 license {
33 name "The Apache Software License, Version 2.0"
34 url "http://www.apache.org/licenses/LICENSE-2.0.txt"
35 distribution "repo"
36 }
37 }
38 developers {
39 developer {
40 id "JetBrains"
41 name "JetBrains Team"
42 organization "JetBrains"
43 organizationUrl "http://www.jetbrains.com"
44 }
45 }
46
47 scm {
48 url "https://github.com/Kotlin/kotlinx.coroutines"
49 }
50}
51
52// --------------- Configure sub-projects with Kotlin sources ---------------
53
54def sourceless = ['site']
55
Roman Elizarove1c0b652017-12-01 14:02:57 +030056static def platformOf(project) {
57 if (project.name.endsWith("-common")) return "common"
58 if (project.name.endsWith("-js")) return "js"
59 return "jvm"
60}
Kirill Timofeeva5186962017-10-25 14:25:47 +030061
Roman Elizarove1c0b652017-12-01 14:02:57 +030062static def platformLib(base, platform) {
63 if (platform == "jvm") return base
64 return "$base-$platform"
65}
66
67configure(subprojects.findAll { !sourceless.contains(it.name) }) {
68 def platform = platformOf(it)
69 apply plugin: "kotlin-platform-$platform"
70
71 if (platform == "jvm") {
72 sourceCompatibility = 1.6
73 targetCompatibility = 1.6
74
75 tasks.withType(JavaCompile) {
76 options.encoding = 'UTF-8'
77 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030078 }
Roman Elizarove1c0b652017-12-01 14:02:57 +030079
Kirill Timofeeva5186962017-10-25 14:25:47 +030080 kotlin.experimental.coroutines "enable"
81
82 tasks.withType(Test) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +030083 testLogging {
84 showStandardStreams = true
85 events "passed", "failed"
86 }
Roman Elizarov94c31682017-10-27 12:20:39 +030087 def stressTest = project.properties['stressTest']
Roman Elizarov6f5bd3f2017-10-26 18:15:00 +030088 if (stressTest != null) systemProperties['stressTest'] = stressTest
Kirill Timofeeva5186962017-10-25 14:25:47 +030089 }
90
91 repositories {
92 jcenter()
Kirill Timofeeva5186962017-10-25 14:25:47 +030093 maven { url "http://kotlin.bintray.com/kotlinx" }
94 maven { url "https://dl.bintray.com/devexperts/Maven/" }
95 }
96
Roman Elizarove1c0b652017-12-01 14:02:57 +030097 def kotlin_stdlib = platformLib("kotlin-stdlib", platform)
Roman Elizarov8bff72b2017-12-20 12:55:38 +030098 def kotlin_test = platformLib("kotlin-test", platform)
Roman Elizarove1c0b652017-12-01 14:02:57 +030099
Kirill Timofeeva5186962017-10-25 14:25:47 +0300100 dependencies {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300101 compile "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
Roman Elizarov8bff72b2017-12-20 12:55:38 +0300102 testCompile "org.jetbrains.kotlin:$kotlin_test:$kotlin_version"
103 }
104
105 if (platform == "common") {
106 dependencies {
107 testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
108 }
109 }
110
111 if (platform == "jvm") {
112 dependencies {
113 testCompile "junit:junit:$junit_version"
114 testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
115 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300116 }
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300117
118 if (platform == "js") {
119 apply from: rootProject.file('gradle/test-js.gradle')
120 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300121}
122
123// --------------- Configure sub-projects that are part of the library ---------------
124
125def internal = sourceless + ['benchmarks', 'knit']
126
Roman Elizarove1c0b652017-12-01 14:02:57 +0300127// configure atomicfu for JVM modules
128configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) {
Kirill Timofeeva5186962017-10-25 14:25:47 +0300129 apply plugin: 'kotlinx-atomicfu'
130
131 dependencies {
132 compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
133 testCompile "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
134 }
135
136 atomicFU {
137 inputFiles = sourceSets.main.output.classesDirs
138 outputDir = file("$buildDir/classes-atomicfu/main")
139 classPath = sourceSets.main.runtimeClasspath
140 }
141
142 jar {
143 mainSpec.sourcePaths.clear() // hack to clear existing paths
144 from files(atomicFU.outputs, sourceSets.main.output.resourcesDir)
145 }
146
147 test {
148 classpath = files(configurations.testRuntime, atomicFU.outputs, sourceSets.test.output.classesDirs,
149 sourceSets.main.output.resourcesDir)
150 }
151}
152
Roman Elizarove1c0b652017-12-01 14:02:57 +0300153// configure dependencies on core
154configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
155 def platform = platformOf(it)
156 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
157
158 if (it.name == coroutines_core) {
159 dependencies {
160 expectedBy project(':kotlinx-coroutines-core-common')
161 }
162 } else {
163 dependencies {
164 compile project(":$coroutines_core")
165 //the only way IDEA can resolve test classes
166 testCompile project(":$coroutines_core").sourceSets.test.output
167 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300168 }
169}
170
171// --------------- Configure sub-projects that are published ---------------
172
173def unpublished = internal + 'kotlinx-coroutines-rx-example'
174
175def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
176def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
177
178configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300179 apply from: rootProject.file('gradle/dokka.gradle')
180 apply from: rootProject.file('gradle/publish-bintray.gradle')
Kirill Timofeeva5186962017-10-25 14:25:47 +0300181}
182
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300183configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300184 def platform = platformOf(it)
185 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
186
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300187 if (it.name != coroutines_core) {
188 dokka.dependsOn project(":$coroutines_core").dokka
189
190 tasks.withType(dokka.getClass()) {
191 externalDocumentationLink {
192 url = new URL(core_docs_url)
193 packageListUrl = new URL("file://$core_docs_file")
194 }
195 }
196 }
197
Roman Elizarove1c0b652017-12-01 14:02:57 +0300198 if (platform == "jvm") {
199 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
200 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300201}
202
203apply plugin: 'base'
204
205clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }