blob: 718be29a73d5ccca64fcdf4b4b7db16e521d8bcb [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" }
Kirill Timofeeva5186962017-10-25 14:25:47 +030017 }
18 dependencies {
19 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
21 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
22 classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
23 }
24}
25
26// --------------- pom configuration ---------------
27
28def pomConfig = {
29 licenses {
30 license {
31 name "The Apache Software License, Version 2.0"
32 url "http://www.apache.org/licenses/LICENSE-2.0.txt"
33 distribution "repo"
34 }
35 }
36 developers {
37 developer {
38 id "JetBrains"
39 name "JetBrains Team"
40 organization "JetBrains"
41 organizationUrl "http://www.jetbrains.com"
42 }
43 }
44
45 scm {
46 url "https://github.com/Kotlin/kotlinx.coroutines"
47 }
48}
49
50// --------------- Configure sub-projects with Kotlin sources ---------------
51
52def sourceless = ['site']
53
Roman Elizarove1c0b652017-12-01 14:02:57 +030054static def platformOf(project) {
55 if (project.name.endsWith("-common")) return "common"
56 if (project.name.endsWith("-js")) return "js"
57 return "jvm"
58}
Kirill Timofeeva5186962017-10-25 14:25:47 +030059
Roman Elizarove1c0b652017-12-01 14:02:57 +030060static def platformLib(base, platform) {
61 if (platform == "jvm") return base
62 return "$base-$platform"
63}
64
65configure(subprojects.findAll { !sourceless.contains(it.name) }) {
66 def platform = platformOf(it)
67 apply plugin: "kotlin-platform-$platform"
68
69 if (platform == "jvm") {
70 sourceCompatibility = 1.6
71 targetCompatibility = 1.6
72
73 tasks.withType(JavaCompile) {
74 options.encoding = 'UTF-8'
75 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030076 }
Roman Elizarove1c0b652017-12-01 14:02:57 +030077
Kirill Timofeeva5186962017-10-25 14:25:47 +030078 kotlin.experimental.coroutines "enable"
79
80 tasks.withType(Test) {
81 testLogging.showStandardStreams = true
Roman Elizarov94c31682017-10-27 12:20:39 +030082 def stressTest = project.properties['stressTest']
Roman Elizarov6f5bd3f2017-10-26 18:15:00 +030083 if (stressTest != null) systemProperties['stressTest'] = stressTest
Kirill Timofeeva5186962017-10-25 14:25:47 +030084 }
85
86 repositories {
87 jcenter()
Kirill Timofeeva5186962017-10-25 14:25:47 +030088 maven { url "http://kotlin.bintray.com/kotlinx" }
89 maven { url "https://dl.bintray.com/devexperts/Maven/" }
90 }
91
Roman Elizarove1c0b652017-12-01 14:02:57 +030092 def kotlin_stdlib = platformLib("kotlin-stdlib", platform)
93
Kirill Timofeeva5186962017-10-25 14:25:47 +030094 dependencies {
Roman Elizarove1c0b652017-12-01 14:02:57 +030095 compile "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030096 testCompile "junit:junit:$junit_version"
97 }
98}
99
100// --------------- Configure sub-projects that are part of the library ---------------
101
102def internal = sourceless + ['benchmarks', 'knit']
103
Roman Elizarove1c0b652017-12-01 14:02:57 +0300104// configure atomicfu for JVM modules
105configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) {
Kirill Timofeeva5186962017-10-25 14:25:47 +0300106 apply plugin: 'kotlinx-atomicfu'
107
108 dependencies {
109 compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
110 testCompile "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
111 }
112
113 atomicFU {
114 inputFiles = sourceSets.main.output.classesDirs
115 outputDir = file("$buildDir/classes-atomicfu/main")
116 classPath = sourceSets.main.runtimeClasspath
117 }
118
119 jar {
120 mainSpec.sourcePaths.clear() // hack to clear existing paths
121 from files(atomicFU.outputs, sourceSets.main.output.resourcesDir)
122 }
123
124 test {
125 classpath = files(configurations.testRuntime, atomicFU.outputs, sourceSets.test.output.classesDirs,
126 sourceSets.main.output.resourcesDir)
127 }
128}
129
Roman Elizarove1c0b652017-12-01 14:02:57 +0300130// configure dependencies on core
131configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
132 def platform = platformOf(it)
133 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
134
135 if (it.name == coroutines_core) {
136 dependencies {
137 expectedBy project(':kotlinx-coroutines-core-common')
138 }
139 } else {
140 dependencies {
141 compile project(":$coroutines_core")
142 //the only way IDEA can resolve test classes
143 testCompile project(":$coroutines_core").sourceSets.test.output
144 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300145 }
146}
147
148// --------------- Configure sub-projects that are published ---------------
149
150def unpublished = internal + 'kotlinx-coroutines-rx-example'
151
152def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
153def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
154
155configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300156 def platform = platformOf(it)
157
Kirill Timofeeva5186962017-10-25 14:25:47 +0300158 apply plugin: 'maven'
159 apply plugin: 'maven-publish'
160 apply plugin: 'org.jetbrains.dokka'
161 apply plugin: 'com.jfrog.bintray'
162
163 dokka {
164 outputFormat = 'kotlin-website'
165 }
166
Roman Elizarove1c0b652017-12-01 14:02:57 +0300167 if (platform == "jvm") {
168 // real xxx-javadoc.jar for JVM
169 task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
170 outputFormat = 'javadoc'
171 outputDirectory = "$buildDir/javadoc"
172 }
173
174 task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
175 classifier = 'javadoc'
176 from "$buildDir/javadoc"
177 }
178 } else {
179 // empty xxx-javadoc.jar
180 task javadocJar(type: Jar) {
181 classifier = 'javadoc'
182 from "$buildDir/javadoc" // would not exist
183 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300184 }
185
186 tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) {
187 jdkVersion = 8
188 includes = ['README.md']
189 linkMapping {
Roman Elizarov8fc00752017-10-27 13:35:36 +0300190 def relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
Kirill Timofeeva5186962017-10-25 14:25:47 +0300191 dir = "$projectDir/src/main/kotlin"
Roman Elizarov8fc00752017-10-27 13:35:36 +0300192 url = "http://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath/src/main/kotlin"
Kirill Timofeeva5186962017-10-25 14:25:47 +0300193 suffix = "#L"
194 }
195 }
196
Kirill Timofeeva5186962017-10-25 14:25:47 +0300197 task sourcesJar(type: Jar, dependsOn: classes) {
198 classifier = 'sources'
199 from sourceSets.main.allSource
200 }
201
202 publishing {
203 publications {
204 maven(MavenPublication) {
Roman Elizaroveb98bc82017-10-27 14:57:08 +0300205 from components.java
Kirill Timofeeva5186962017-10-25 14:25:47 +0300206 artifact javadocJar
207 artifact sourcesJar
208 pom.withXml {
209 def root = asNode()
210 root.appendNode('name', project.name)
211 root.appendNode('description', 'Coroutines support libraries for Kotlin')
212 root.appendNode('url', 'https://github.com/Kotlin/kotlinx.coroutines')
213 root.children().last() + pomConfig
214 }
215 }
216 }
217 }
218
219 bintray {
220 user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
221 key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
222 publications = ['maven']
223 pkg {
224 userOrg = 'kotlin'
225 repo = 'kotlinx'
226 name = 'kotlinx.coroutines'
227 version {
228 name = project.version
229 vcsTag = project.version
230 released = new Date()
231 }
232 }
233 }
Roman Elizarovba5e5da2017-10-27 14:02:55 +0300234
235 bintrayUpload.doLast {
236 println("Uploaded $project.name version $project.version")
237 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300238}
239
Roman Elizarove1c0b652017-12-01 14:02:57 +0300240configure(subprojects.findAll { !unpublished.contains(it.name) && it.name != 'kotlinx-coroutines-core-common' }) {
241 def platform = platformOf(it)
242 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
243
244 dokka.dependsOn project(":$coroutines_core").dokka
245 if (platform == "jvm") {
246 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
247 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300248
249 tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) {
250 externalDocumentationLink {
251 url = new URL(core_docs_url)
252 packageListUrl = new URL("file://$core_docs_file")
253 }
254 }
255}
256
257apply plugin: 'base'
258
259clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }