Skip to content

Commit 65eff0b

Browse files
committed
MPP: Build logic organization/refactoring & Kotlin/JS tests with Mocha
1 parent 8bff72b commit 65eff0b

File tree

7 files changed

+160
-93
lines changed

7 files changed

+160
-93
lines changed

build.gradle

Lines changed: 24 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ buildscript {
1414
repositories {
1515
jcenter()
1616
maven { url "http://kotlin.bintray.com/kotlinx" }
17+
maven { url "https://plugins.gradle.org/m2/" }
1718
}
1819
dependencies {
1920
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2021
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
2122
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
22-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
23+
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
24+
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
2325
}
2426
}
2527

@@ -78,7 +80,10 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {
7880
kotlin.experimental.coroutines "enable"
7981

8082
tasks.withType(Test) {
81-
testLogging.showStandardStreams = true
83+
testLogging {
84+
showStandardStreams = true
85+
events "passed", "failed"
86+
}
8287
def stressTest = project.properties['stressTest']
8388
if (stressTest != null) systemProperties['stressTest'] = stressTest
8489
}
@@ -109,6 +114,10 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {
109114
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
110115
}
111116
}
117+
118+
if (platform == "js") {
119+
apply from: rootProject.file('gradle/test-js.gradle')
120+
}
112121
}
113122

114123
// --------------- Configure sub-projects that are part of the library ---------------
@@ -167,105 +176,28 @@ def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-corouti
167176
def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
168177

169178
configure(subprojects.findAll { !unpublished.contains(it.name) }) {
170-
def platform = platformOf(it)
171-
172-
apply plugin: 'maven'
173-
apply plugin: 'maven-publish'
174-
apply plugin: 'org.jetbrains.dokka'
175-
apply plugin: 'com.jfrog.bintray'
176-
177-
dokka {
178-
outputFormat = 'kotlin-website'
179-
}
180-
181-
if (platform == "jvm") {
182-
// real xxx-javadoc.jar for JVM
183-
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
184-
outputFormat = 'javadoc'
185-
outputDirectory = "$buildDir/javadoc"
186-
}
187-
188-
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
189-
classifier = 'javadoc'
190-
from "$buildDir/javadoc"
191-
}
192-
} else {
193-
// empty xxx-javadoc.jar
194-
task javadocJar(type: Jar) {
195-
classifier = 'javadoc'
196-
from "$buildDir/javadoc" // would not exist
197-
}
198-
}
199-
200-
tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) {
201-
jdkVersion = 8
202-
includes = ['README.md']
203-
linkMapping {
204-
def relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
205-
dir = "$projectDir/src/main/kotlin"
206-
url = "http://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath/src/main/kotlin"
207-
suffix = "#L"
208-
}
209-
}
179+
apply from: rootProject.file('gradle/dokka.gradle')
180+
apply from: rootProject.file('gradle/publish-bintray.gradle')
181+
}
210182

211-
task sourcesJar(type: Jar, dependsOn: classes) {
212-
classifier = 'sources'
213-
from sourceSets.main.allSource
214-
}
183+
configure(subprojects.findAll { !unpublished.contains(it.name) }) {
184+
def platform = platformOf(it)
185+
def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
215186

216-
publishing {
217-
publications {
218-
maven(MavenPublication) {
219-
from components.java
220-
artifact javadocJar
221-
artifact sourcesJar
222-
pom.withXml {
223-
def root = asNode()
224-
root.appendNode('name', project.name)
225-
root.appendNode('description', 'Coroutines support libraries for Kotlin')
226-
root.appendNode('url', 'https://github.com/Kotlin/kotlinx.coroutines')
227-
root.children().last() + pomConfig
228-
}
229-
}
230-
}
231-
}
187+
if (it.name != coroutines_core) {
188+
dokka.dependsOn project(":$coroutines_core").dokka
232189

233-
bintray {
234-
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
235-
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
236-
publications = ['maven']
237-
pkg {
238-
userOrg = 'kotlin'
239-
repo = 'kotlinx'
240-
name = 'kotlinx.coroutines'
241-
version {
242-
name = project.version
243-
vcsTag = project.version
244-
released = new Date()
190+
tasks.withType(dokka.getClass()) {
191+
externalDocumentationLink {
192+
url = new URL(core_docs_url)
193+
packageListUrl = new URL("file://$core_docs_file")
245194
}
246195
}
247196
}
248-
249-
bintrayUpload.doLast {
250-
println("Uploaded $project.name version $project.version")
251-
}
252-
}
253-
254-
configure(subprojects.findAll { !unpublished.contains(it.name) && it.name != 'kotlinx-coroutines-core-common' }) {
255-
def platform = platformOf(it)
256-
def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
257-
258-
dokka.dependsOn project(":$coroutines_core").dokka
197+
259198
if (platform == "jvm") {
260199
dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
261200
}
262-
263-
tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) {
264-
externalDocumentationLink {
265-
url = new URL(core_docs_url)
266-
packageListUrl = new URL("file://$core_docs_file")
267-
}
268-
}
269201
}
270202

271203
apply plugin: 'base'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package kotlinx.coroutines.experimental
2+

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
version = 0.20-SNAPSHOT
22

3-
kotlin_version = 1.2.0
3+
kotlin_version = 1.2.10
44
junit_version = 4.12
55
atomicFU_version = 0.9.2
66
lincheck_version=1.9
77
dokka_version = 0.9.15
8+
bintray_version = 1.7.3
9+
gradle_node_version = 1.2.0
810

gradle/dokka.gradle

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Configures generation of JavaDoc & Dokka artifacts
2+
3+
def platform = platformOf(project)
4+
5+
apply plugin: 'org.jetbrains.dokka'
6+
7+
dokka {
8+
outputFormat = 'kotlin-website'
9+
}
10+
11+
if (platform == "jvm") {
12+
// real xxx-javadoc.jar for JVM
13+
task dokkaJavadoc(type: dokka.getClass()) {
14+
outputFormat = 'javadoc'
15+
outputDirectory = "$buildDir/javadoc"
16+
}
17+
18+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
19+
classifier = 'javadoc'
20+
from "$buildDir/javadoc"
21+
}
22+
} else {
23+
// empty xxx-javadoc.jar
24+
task javadocJar(type: Jar) {
25+
classifier = 'javadoc'
26+
from "$buildDir/javadoc" // would not exist
27+
}
28+
}
29+
30+
tasks.withType(dokka.getClass()) {
31+
jdkVersion = 8
32+
includes = ['README.md']
33+
linkMapping {
34+
def relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
35+
dir = "$projectDir/src/main/kotlin"
36+
url = "http://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath/src/main/kotlin"
37+
suffix = "#L"
38+
}
39+
}

gradle/publish-bintray.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Configures publishing of Maven artifacts to Bintray
2+
3+
apply plugin: 'maven'
4+
apply plugin: 'maven-publish'
5+
apply plugin: 'com.jfrog.bintray'
6+
7+
task sourcesJar(type: Jar, dependsOn: classes) {
8+
classifier = 'sources'
9+
from sourceSets.main.allSource
10+
}
11+
12+
publishing {
13+
publications {
14+
maven(MavenPublication) {
15+
from components.java
16+
artifact javadocJar
17+
artifact sourcesJar
18+
pom.withXml {
19+
def root = asNode()
20+
root.appendNode('name', project.name)
21+
root.appendNode('description', 'Coroutines support libraries for Kotlin')
22+
root.appendNode('url', 'https://github.com/Kotlin/kotlinx.coroutines')
23+
root.children().last() + pomConfig
24+
}
25+
}
26+
}
27+
}
28+
29+
bintray {
30+
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
31+
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
32+
publications = ['maven']
33+
pkg {
34+
userOrg = 'kotlin'
35+
repo = 'kotlinx'
36+
name = 'kotlinx.coroutines'
37+
version {
38+
name = project.version
39+
vcsTag = project.version
40+
released = new Date()
41+
}
42+
}
43+
}
44+
45+
bintrayUpload.doLast {
46+
println("Uploaded $project.name version $project.version")
47+
}

gradle/test-js.gradle

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Configures testing for JS modules
2+
3+
apply plugin: 'com.moowork.node'
4+
5+
tasks.withType(compileKotlin2Js.getClass()) {
6+
kotlinOptions {
7+
moduleKind = "umd"
8+
sourceMap = true
9+
metaInfo = true
10+
}
11+
}
12+
13+
task populateNodeModules(type: Copy, dependsOn: compileKotlin2Js) {
14+
from compileKotlin2Js.destinationDir
15+
16+
configurations.testCompile.each {
17+
from zipTree(it.absolutePath).matching {
18+
include '*.js'
19+
include '*.js.map'
20+
}
21+
}
22+
23+
into "${buildDir}/node_modules"
24+
}
25+
26+
node {
27+
download = true
28+
}
29+
30+
task installDependencies(type: NpmTask) {
31+
args = ['install', 'mocha', 'source-map-support']
32+
if (project.hasProperty("teamcity")) args += 'mocha-teamcity-reporter'
33+
}
34+
35+
task prepareMocha(dependsOn: [compileTestKotlin2Js, populateNodeModules, installDependencies])
36+
37+
task runMocha(type: NodeTask, dependsOn: prepareMocha) {
38+
script = file('node_modules/mocha/bin/mocha')
39+
args = [compileTestKotlin2Js.outputFile, '--require=source-map-support/register']
40+
if (project.hasProperty("teamcity")) args += '--reporter=mocha-teamcity-reporter'
41+
}
42+
43+
test.dependsOn runMocha
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package kotlinx.coroutines.experimental
2+

0 commit comments

Comments
 (0)