@@ -6,65 +6,67 @@ allprojects {
66
77buildscript {
88 if (System . properties[' kotlinSnapshot' ] != null ) {
9- ext. kotlin_version = ' 1.1 -SNAPSHOT'
9+ ext. kotlin_version = ' 1.2 -SNAPSHOT'
1010 repositories {
1111 maven { url " https://oss.sonatype.org/content/repositories/snapshots" }
1212 }
1313 }
1414 repositories {
1515 jcenter()
1616 maven { url " http://kotlin.bintray.com/kotlinx" }
17+ maven { url " http://kotlin.bintray.com/kotlin-dev" }
18+ maven { url " https://plugins.gradle.org/m2/" }
1719 }
1820 dependencies {
1921 classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
2022 classpath " org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version "
2123 classpath " org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version "
22- classpath ' com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
24+ classpath " com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version "
25+ classpath " com.moowork.gradle:gradle-node-plugin:$gradle_node_version "
2326 }
2427}
2528
26- // --------------- pom configuration ---------------
29+ // --------------- Configure sub-projects with Kotlin sources ---------------
2730
28- def 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- }
31+ def sourceless = [' site' ]
4432
45- scm {
46- url " https://github.com/Kotlin/kotlinx.coroutines"
47- }
33+ static def platformOf (project ) {
34+ if (project. name. endsWith(" -common" )) return " common"
35+ if (project. name. endsWith(" -js" )) return " js"
36+ return " jvm"
4837}
4938
50- // --------------- Configure sub-projects with Kotlin sources ---------------
51-
52- def sourceless = [' site' ]
39+ static def platformLib (base , platform ) {
40+ if (platform == " jvm" ) return base
41+ return " $base -$platform "
42+ }
5343
5444configure(subprojects. findAll { ! sourceless. contains(it. name) }) {
55- apply plugin : ' kotlin'
45+ def platform = platformOf(it)
46+ apply plugin : " kotlin-platform-$platform "
5647
57- sourceCompatibility = 1.6
58- targetCompatibility = 1.6
59-
60- tasks. withType(JavaCompile ) {
61- options. encoding = ' UTF-8'
48+ if (platform == " jvm" ) {
49+ sourceCompatibility = 1.6
50+ targetCompatibility = 1.6
6251 }
63-
52+
6453 kotlin. experimental. coroutines " enable"
6554
55+ if (platform == " js" ) {
56+ tasks. withType(compileKotlin2Js. getClass()) {
57+ kotlinOptions {
58+ moduleKind = " umd"
59+ sourceMap = true
60+ metaInfo = true
61+ }
62+ }
63+ }
64+
6665 tasks. withType(Test ) {
67- testLogging. showStandardStreams = true
66+ testLogging {
67+ showStandardStreams = true
68+ events " passed" , " failed"
69+ }
6870 def stressTest = project. properties[' stressTest' ]
6971 if (stressTest != null ) systemProperties[' stressTest' ] = stressTest
7072 }
@@ -75,17 +77,34 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {
7577 maven { url " https://dl.bintray.com/devexperts/Maven/" }
7678 }
7779
80+ def kotlin_stdlib = platformLib(" kotlin-stdlib" , platform)
81+ def kotlin_test = platformLib(" kotlin-test" , platform)
82+
7883 dependencies {
79- compile " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
80- testCompile " junit:junit:$junit_version "
84+ compile " org.jetbrains.kotlin:$kotlin_stdlib :$kotlin_version "
85+ testCompile " org.jetbrains.kotlin:$kotlin_test :$kotlin_version "
86+ }
87+
88+ if (platform == " common" ) {
89+ dependencies {
90+ testCompile " org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version "
91+ }
92+ }
93+
94+ if (platform == " jvm" ) {
95+ dependencies {
96+ testCompile " junit:junit:$junit_version "
97+ testCompile " org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version "
98+ }
8199 }
82100}
83101
84102// --------------- Configure sub-projects that are part of the library ---------------
85103
86- def internal = sourceless + [' benchmarks' , ' knit' ]
104+ def internal = sourceless + [' benchmarks' , ' knit' , ' js-stub ' ]
87105
88- configure(subprojects. findAll { ! internal. contains(it. name) }) {
106+ // configure atomicfu for JVM modules
107+ configure(subprojects. findAll { ! internal. contains(it. name) && platformOf(it) == " jvm" }) {
89108 apply plugin : ' kotlinx-atomicfu'
90109
91110 dependencies {
@@ -110,104 +129,53 @@ configure(subprojects.findAll { !internal.contains(it.name) }) {
110129 }
111130}
112131
113- configure(subprojects. findAll { ! internal. contains(it. name) && it. name != ' kotlinx-coroutines-core' }) {
114- dependencies {
115- compile project(' :kotlinx-coroutines-core' )
116- // the only way IDEA can resolve test classes
117- testCompile project(' :kotlinx-coroutines-core' ). sourceSets. test. output
132+ // configure dependencies on core
133+ configure(subprojects. findAll { ! internal. contains(it. name) && it. name != ' kotlinx-coroutines-core-common' }) {
134+ def platform = platformOf(it)
135+ def coroutines_core = platformLib(" kotlinx-coroutines-core" , platform)
136+
137+ if (it. name == coroutines_core) {
138+ dependencies {
139+ expectedBy project(' :kotlinx-coroutines-core-common' )
140+ }
141+ } else {
142+ dependencies {
143+ compile project(" :$coroutines_core " )
144+ // the only way IDEA can resolve test classes
145+ testCompile project(" :$coroutines_core " ). sourceSets. test. output
146+ }
118147 }
119148}
120149
121150// --------------- Configure sub-projects that are published ---------------
122151
123- def unpublished = internal + ' kotlinx-coroutines-rx-example'
152+ def unpublished = internal + [ ' kotlinx-coroutines-rx-example' , ' example-frontend-js ' ]
124153
125154def core_docs_url = " https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
126155def core_docs_file = " $projectDir /core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
127156
128157configure(subprojects. findAll { ! unpublished. contains(it. name) }) {
129- apply plugin : ' maven'
130- apply plugin : ' maven-publish'
131- apply plugin : ' org.jetbrains.dokka'
132- apply plugin : ' com.jfrog.bintray'
133-
134- dokka {
135- outputFormat = ' kotlin-website'
136- }
137-
138- task dokkaJavadoc(type : org.jetbrains.dokka.gradle.DokkaTask ) {
139- outputFormat = ' javadoc'
140- outputDirectory = " $buildDir /javadoc"
141- }
142-
143- tasks. withType(org.jetbrains.dokka.gradle.DokkaTask ) {
144- jdkVersion = 8
145- includes = [' README.md' ]
146- linkMapping {
147- def relPath = rootProject. projectDir. toPath(). relativize(projectDir. toPath())
148- dir = " $projectDir /src/main/kotlin"
149- url = " http://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath /src/main/kotlin"
150- suffix = " #L"
151- }
152- }
153-
154- task javadocJar(type : Jar , dependsOn : dokkaJavadoc) {
155- classifier = ' javadoc'
156- from " $buildDir /javadoc"
157- }
158+ apply from : rootProject. file(' gradle/dokka.gradle' )
159+ apply from : rootProject. file(' gradle/publish-bintray.gradle' )
160+ }
158161
159- task sourcesJar(type : Jar , dependsOn : classes) {
160- classifier = ' sources'
161- from sourceSets. main. allSource
162- }
162+ configure(subprojects. findAll { ! unpublished. contains(it. name) }) {
163+ def platform = platformOf(it)
164+ def coroutines_core = platformLib(" kotlinx-coroutines-core" , platform)
163165
164- publishing {
165- publications {
166- maven(MavenPublication ) {
167- from components. java
168- artifact javadocJar
169- artifact sourcesJar
170- pom. withXml {
171- def root = asNode()
172- root. appendNode(' name' , project. name)
173- root. appendNode(' description' , ' Coroutines support libraries for Kotlin' )
174- root. appendNode(' url' , ' https://github.com/Kotlin/kotlinx.coroutines' )
175- root. children(). last() + pomConfig
176- }
177- }
178- }
179- }
166+ if (it. name != coroutines_core) {
167+ dokka. dependsOn project(" :$coroutines_core " ). dokka
180168
181- bintray {
182- user = project. hasProperty(' bintrayUser' ) ? project. property(' bintrayUser' ) : System . getenv(' BINTRAY_USER' )
183- key = project. hasProperty(' bintrayApiKey' ) ? project. property(' bintrayApiKey' ) : System . getenv(' BINTRAY_API_KEY' )
184- publications = [' maven' ]
185- pkg {
186- userOrg = ' kotlin'
187- repo = ' kotlinx'
188- name = ' kotlinx.coroutines'
189- version {
190- name = project. version
191- vcsTag = project. version
192- released = new Date ()
169+ tasks. withType(dokka. getClass()) {
170+ externalDocumentationLink {
171+ url = new URL (core_docs_url)
172+ packageListUrl = new URL (" file://$core_docs_file " )
193173 }
194174 }
195175 }
196-
197- bintrayUpload. doLast {
198- println (" Uploaded $project . name version $project . version " )
199- }
200- }
201-
202- configure(subprojects. findAll { ! unpublished. contains(it. name) && it. name != ' kotlinx-coroutines-core' }) {
203- dokka. dependsOn project(' :kotlinx-coroutines-core' ). dokka
204- dokkaJavadoc. dependsOn project(' :kotlinx-coroutines-core' ). dokka
205-
206- tasks. withType(org.jetbrains.dokka.gradle.DokkaTask ) {
207- externalDocumentationLink {
208- url = new URL (core_docs_url)
209- packageListUrl = new URL (" file://$core_docs_file " )
210- }
176+
177+ if (platform == " jvm" ) {
178+ dokkaJavadoc. dependsOn project(" :$coroutines_core " ). dokka
211179 }
212180}
213181
0 commit comments