Skip to content

Commit 3145290

Browse files
committed
Restructure build logic, prepare for native
1 parent e1a5652 commit 3145290

12 files changed

+167
-100
lines changed

build.gradle

+11-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
allprojects {
2-
group = 'org.jetbrains.kotlinx'
32
def deployVersion = properties['DeployVersion']
43
if (deployVersion != null) version = deployVersion
54
}
@@ -13,12 +12,14 @@ buildscript {
1312
}
1413
repositories {
1514
jcenter()
16-
maven { url "http://kotlin.bintray.com/kotlinx" }
17-
maven { url "http://kotlin.bintray.com/kotlin-dev" }
15+
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" }
1818
maven { url "https://plugins.gradle.org/m2/" }
1919
}
2020
dependencies {
2121
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
22+
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
2223
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
2324
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
2425
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
@@ -36,6 +37,7 @@ def sourceless = ['site']
3637
static def platformOf(project) {
3738
if (project.name.endsWith("-common")) return "common"
3839
if (project.name.endsWith("-js")) return "js"
40+
if (project.name.endsWith("-native")) return "native"
3941
return "jvm"
4042
}
4143

@@ -47,37 +49,16 @@ static def platformLib(base, platform) {
4749
configure(subprojects.findAll { !sourceless.contains(it.name) }) {
4850
def platform = platformOf(it)
4951
apply from: rootProject.file("gradle/compile-${platform}.gradle")
50-
apply from: rootProject.file("gradle/compile-all.gradle")
5152
}
5253

5354
// --------------- Configure sub-projects that are part of the library ---------------
5455

5556
def internal = sourceless + ['benchmarks', 'knit', 'js-stub']
5657

57-
// configure atomicfu for JVM modules
58-
configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) {
59-
apply plugin: 'kotlinx-atomicfu'
60-
61-
dependencies {
62-
compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
63-
testCompile "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
64-
}
65-
66-
atomicFU {
67-
inputFiles = sourceSets.main.output.classesDirs
68-
outputDir = file("$buildDir/classes-atomicfu/main")
69-
classPath = sourceSets.main.runtimeClasspath
70-
}
71-
72-
jar {
73-
mainSpec.sourcePaths.clear() // hack to clear existing paths
74-
from files(atomicFU.outputs, sourceSets.main.output.resourcesDir)
75-
}
76-
77-
test {
78-
classpath = files(configurations.testRuntime, atomicFU.outputs, sourceSets.test.output.classesDirs,
79-
sourceSets.main.output.resourcesDir)
80-
}
58+
// configure atomicfu
59+
configure(subprojects.findAll { !internal.contains(it.name) }) {
60+
def platform = platformOf(it)
61+
apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
8162
}
8263

8364
// configure dependencies on core
@@ -100,7 +81,8 @@ configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotli
10081

10182
// --------------- Configure sub-projects that are published ---------------
10283

103-
def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js']
84+
// todo: native is not published yet
85+
def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'kotlinx-coroutines-core-native']
10486

10587
def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
10688
def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"

gradle.properties

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
version = 0.22.5-SNAPSHOT
2+
group = org.jetbrains.kotlinx
23

3-
kotlin_version = 1.2.30
4+
kotlin_version = 1.2.31
5+
kotlin_native_version = 0.7-dev-1436
46
junit_version = 4.12
5-
atomicFU_version = 0.9.2
7+
atomicFU_version = 0.10.0-alpha
68
html_version = 0.6.8
79
lincheck_version=1.9
810
dokka_version = 0.9.16-dev-mpp-hacks-1

gradle/atomicfu-common.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
dependencies {
3+
compile "org.jetbrains.kotlinx:atomicfu-common:$atomicFU_version"
4+
}

gradle/atomicfu-js.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
dependencies {
3+
compile "org.jetbrains.kotlinx:atomicfu-js:$atomicFU_version"
4+
}

gradle/atomicfu-jvm.gradle

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apply plugin: 'kotlinx-atomicfu'
2+
3+
dependencies {
4+
compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
5+
testCompile "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
6+
}
7+
8+
atomicFU {
9+
inputFiles = sourceSets.main.output.classesDirs
10+
outputDir = file("$buildDir/classes-atomicfu/main")
11+
classPath = sourceSets.main.runtimeClasspath
12+
}
13+
14+
jar {
15+
mainSpec.sourcePaths.clear() // hack to clear existing paths
16+
from files(atomicFU.outputs, sourceSets.main.output.resourcesDir)
17+
}
18+
19+
test {
20+
classpath = files(configurations.testRuntime, atomicFU.outputs, sourceSets.test.output.classesDirs,
21+
sourceSets.main.output.resourcesDir)
22+
}

gradle/atomicfu-native.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
// todo: this does not work in Kotlin/Native
3+
4+
//dependencies {
5+
// compile "org.jetbrains.kotlinx:atomicfu-native:$atomicFU_version"
6+
//}

gradle/compile-all.gradle

-19
This file was deleted.

gradle/compile-common.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33

44
apply plugin: 'kotlin-platform-common'
55

6+
kotlin.experimental.coroutines "enable"
7+
68
dependencies {
79
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
810
testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
911
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
1012
}
1113

14+
repositories {
15+
jcenter()
16+
maven { url "https://kotlin.bintray.com/kotlinx" }
17+
}

gradle/compile-js.gradle

+17-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,31 @@
33

44
apply plugin: 'kotlin-platform-js'
55

6+
kotlin.experimental.coroutines "enable"
7+
8+
dependencies {
9+
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
10+
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
11+
}
12+
13+
repositories {
14+
jcenter()
15+
maven { url "https://kotlin.bintray.com/kotlinx" }
16+
}
17+
618
tasks.withType(compileKotlin2Js.getClass()) {
719
kotlinOptions {
820
moduleKind = "umd"
921
sourceMap = true
1022
metaInfo = true
23+
}
24+
}
25+
26+
compileKotlin2Js {
27+
kotlinOptions {
1128
// drop -js suffix from outputFile
1229
def baseName = project.name - "-js"
1330
outputFile = new File(outputFile.parent, baseName + ".js")
1431
}
1532
}
1633

17-
dependencies {
18-
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
19-
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
20-
}

gradle/compile-jvm.gradle

+17
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,26 @@ apply plugin: 'kotlin-platform-jvm'
66
sourceCompatibility = 1.6
77
targetCompatibility = 1.6
88

9+
kotlin.experimental.coroutines "enable"
10+
911
dependencies {
1012
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
1113
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
1214
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
1315
testCompile "junit:junit:$junit_version"
1416
}
17+
18+
repositories {
19+
jcenter()
20+
maven { url "https://kotlin.bintray.com/kotlinx" }
21+
maven { url "https://dl.bintray.com/devexperts/Maven/" }
22+
}
23+
24+
tasks.withType(Test) {
25+
testLogging {
26+
showStandardStreams = true
27+
events "passed", "failed"
28+
}
29+
def stressTest = project.properties['stressTest']
30+
if (stressTest != null) systemProperties['stressTest'] = stressTest
31+
}

gradle/compile-native.gradle

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apply plugin: 'konan'
2+
3+
repositories {
4+
jcenter()
5+
maven { url "https://kotlin.bintray.com/kotlinx" }
6+
}
7+
8+
def libraryName = project.name
9+
def testProgramName = libraryName + "-test"
10+
11+
konanArtifacts {
12+
library(libraryName, targets: ["ios_arm64", "ios_x64", "macos_x64"]) {
13+
artifactName libraryName.replace('-', '_')
14+
enableMultiplatform true
15+
dependencies {
16+
"artifact$libraryName" "org.jetbrains.kotlinx:atomicfu-native:$atomicFU_version"
17+
}
18+
}
19+
// TODO: THIS IS A WORKAROUND: Cannot do tests together with publishing in Kotlin/Native
20+
if (!rootProject.properties["publish"]) {
21+
program(testProgramName, targets: ["macos_x64"]) {
22+
srcDir 'src/test/kotlin'
23+
commonSourceSet 'test'
24+
libraries {
25+
artifact libraryName
26+
}
27+
extraOpts '-tr'
28+
}
29+
}
30+
}
31+
32+
task test(dependsOn: run)
33+
34+
// TODO: THIS IS A WORKAROUND: Cannot do tests together with publishing in Kotlin/Native
35+
if (rootProject.properties["publish"]) {
36+
publishToMavenLocal.dependsOn(build)
37+
}

settings.gradle

+39-46
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
11
rootProject.name = 'kotlinx.coroutines'
22

3-
include 'kotlinx-coroutines-core-common'
4-
5-
include 'kotlinx-coroutines-core'
6-
include 'kotlinx-coroutines-io'
7-
8-
include 'kotlinx-coroutines-guava'
9-
include 'kotlinx-coroutines-jdk8'
10-
include 'kotlinx-coroutines-nio'
11-
include 'kotlinx-coroutines-quasar'
12-
13-
include 'kotlinx-coroutines-reactive'
14-
include 'kotlinx-coroutines-reactor'
15-
include 'kotlinx-coroutines-rx1'
16-
include 'kotlinx-coroutines-rx2'
17-
include 'kotlinx-coroutines-rx-example'
18-
19-
include 'kotlinx-coroutines-android'
20-
include 'kotlinx-coroutines-javafx'
21-
include 'kotlinx-coroutines-swing'
22-
23-
include 'kotlinx-coroutines-core-js'
24-
include 'js-stub'
25-
include 'example-frontend-js'
26-
27-
include 'benchmarks'
28-
include 'knit'
29-
include 'site'
30-
31-
project(':kotlinx-coroutines-core-common').projectDir = file('common/kotlinx-coroutines-core-common')
32-
project(':kotlinx-coroutines-core').projectDir = file('core/kotlinx-coroutines-core')
33-
project(':kotlinx-coroutines-io').projectDir = file('core/kotlinx-coroutines-io')
34-
project(':kotlinx-coroutines-guava').projectDir = file('integration/kotlinx-coroutines-guava')
35-
project(':kotlinx-coroutines-jdk8').projectDir = file('integration/kotlinx-coroutines-jdk8')
36-
project(':kotlinx-coroutines-nio').projectDir = file('integration/kotlinx-coroutines-nio')
37-
project(':kotlinx-coroutines-quasar').projectDir = file('integration/kotlinx-coroutines-quasar')
38-
project(':kotlinx-coroutines-reactive').projectDir = file('reactive/kotlinx-coroutines-reactive')
39-
project(':kotlinx-coroutines-reactor').projectDir = file('reactive/kotlinx-coroutines-reactor')
40-
project(':kotlinx-coroutines-rx1').projectDir = file('reactive/kotlinx-coroutines-rx1')
41-
project(':kotlinx-coroutines-rx2').projectDir = file('reactive/kotlinx-coroutines-rx2')
42-
project(':kotlinx-coroutines-rx-example').projectDir = file('reactive/kotlinx-coroutines-rx-example')
43-
project(':kotlinx-coroutines-android').projectDir = file('ui/kotlinx-coroutines-android')
44-
project(':kotlinx-coroutines-javafx').projectDir = file('ui/kotlinx-coroutines-javafx')
45-
project(':kotlinx-coroutines-swing').projectDir = file('ui/kotlinx-coroutines-swing')
46-
project(':kotlinx-coroutines-core-js').projectDir = file('js/kotlinx-coroutines-core-js')
47-
project(':js-stub').projectDir = file('js/js-stub')
48-
project(':example-frontend-js').projectDir = file('js/example-frontend-js')
3+
def module(String path) {
4+
int i = path.lastIndexOf('/')
5+
def name = path.substring(i + 1)
6+
include(name)
7+
project(":$name").projectDir = file(path)
8+
}
9+
10+
// ---------------------------
11+
12+
include('benchmarks')
13+
include('knit')
14+
include('site')
15+
16+
module('common/kotlinx-coroutines-core-common')
17+
18+
module('core/kotlinx-coroutines-core')
19+
module('core/kotlinx-coroutines-io')
20+
21+
module('integration/kotlinx-coroutines-guava')
22+
module('integration/kotlinx-coroutines-jdk8')
23+
module('integration/kotlinx-coroutines-nio')
24+
module('integration/kotlinx-coroutines-quasar')
25+
26+
module('reactive/kotlinx-coroutines-reactive')
27+
module('reactive/kotlinx-coroutines-reactor')
28+
module('reactive/kotlinx-coroutines-rx1')
29+
module('reactive/kotlinx-coroutines-rx2')
30+
module('reactive/kotlinx-coroutines-rx-example')
31+
32+
module('ui/kotlinx-coroutines-android')
33+
module('ui/kotlinx-coroutines-javafx')
34+
module('ui/kotlinx-coroutines-swing')
35+
36+
module('js/kotlinx-coroutines-core-js')
37+
module('js/js-stub')
38+
module('js/example-frontend-js')
39+
40+
//module('native/kotlinx-coroutines-core-native')
41+

0 commit comments

Comments
 (0)