Skip to content

Commit

Permalink
Restructure build logic, prepare for native
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov committed Apr 11, 2018
1 parent e1a5652 commit 3145290
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 100 deletions.
40 changes: 11 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
allprojects {
group = 'org.jetbrains.kotlinx'
def deployVersion = properties['DeployVersion']
if (deployVersion != null) version = deployVersion
}
Expand All @@ -13,12 +12,14 @@ buildscript {
}
repositories {
jcenter()
maven { url "http:https://kotlin.bintray.com/kotlinx" }
maven { url "http:https://kotlin.bintray.com/kotlin-dev" }
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://kotlin.bintray.com/kotlin-dev" }
maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
Expand All @@ -36,6 +37,7 @@ def sourceless = ['site']
static def platformOf(project) {
if (project.name.endsWith("-common")) return "common"
if (project.name.endsWith("-js")) return "js"
if (project.name.endsWith("-native")) return "native"
return "jvm"
}

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

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

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

// configure atomicfu for JVM modules
configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) {
apply plugin: 'kotlinx-atomicfu'

dependencies {
compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
testCompile "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
}

atomicFU {
inputFiles = sourceSets.main.output.classesDirs
outputDir = file("$buildDir/classes-atomicfu/main")
classPath = sourceSets.main.runtimeClasspath
}

jar {
mainSpec.sourcePaths.clear() // hack to clear existing paths
from files(atomicFU.outputs, sourceSets.main.output.resourcesDir)
}

test {
classpath = files(configurations.testRuntime, atomicFU.outputs, sourceSets.test.output.classesDirs,
sourceSets.main.output.resourcesDir)
}
// configure atomicfu
configure(subprojects.findAll { !internal.contains(it.name) }) {
def platform = platformOf(it)
apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
}

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

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

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

def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version = 0.22.5-SNAPSHOT
group = org.jetbrains.kotlinx

kotlin_version = 1.2.30
kotlin_version = 1.2.31
kotlin_native_version = 0.7-dev-1436
junit_version = 4.12
atomicFU_version = 0.9.2
atomicFU_version = 0.10.0-alpha
html_version = 0.6.8
lincheck_version=1.9
dokka_version = 0.9.16-dev-mpp-hacks-1
Expand Down
4 changes: 4 additions & 0 deletions gradle/atomicfu-common.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

dependencies {
compile "org.jetbrains.kotlinx:atomicfu-common:$atomicFU_version"
}
4 changes: 4 additions & 0 deletions gradle/atomicfu-js.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

dependencies {
compile "org.jetbrains.kotlinx:atomicfu-js:$atomicFU_version"
}
22 changes: 22 additions & 0 deletions gradle/atomicfu-jvm.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apply plugin: 'kotlinx-atomicfu'

dependencies {
compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
testCompile "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
}

atomicFU {
inputFiles = sourceSets.main.output.classesDirs
outputDir = file("$buildDir/classes-atomicfu/main")
classPath = sourceSets.main.runtimeClasspath
}

jar {
mainSpec.sourcePaths.clear() // hack to clear existing paths
from files(atomicFU.outputs, sourceSets.main.output.resourcesDir)
}

test {
classpath = files(configurations.testRuntime, atomicFU.outputs, sourceSets.test.output.classesDirs,
sourceSets.main.output.resourcesDir)
}
6 changes: 6 additions & 0 deletions gradle/atomicfu-native.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// todo: this does not work in Kotlin/Native

//dependencies {
// compile "org.jetbrains.kotlinx:atomicfu-native:$atomicFU_version"
//}
19 changes: 0 additions & 19 deletions gradle/compile-all.gradle

This file was deleted.

6 changes: 6 additions & 0 deletions gradle/compile-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

apply plugin: 'kotlin-platform-common'

kotlin.experimental.coroutines "enable"

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
}

repositories {
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
21 changes: 17 additions & 4 deletions gradle/compile-js.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@

apply plugin: 'kotlin-platform-js'

kotlin.experimental.coroutines "enable"

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

repositories {
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
}

tasks.withType(compileKotlin2Js.getClass()) {
kotlinOptions {
moduleKind = "umd"
sourceMap = true
metaInfo = true
}
}

compileKotlin2Js {
kotlinOptions {
// drop -js suffix from outputFile
def baseName = project.name - "-js"
outputFile = new File(outputFile.parent, baseName + ".js")
}
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}
17 changes: 17 additions & 0 deletions gradle/compile-jvm.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@ apply plugin: 'kotlin-platform-jvm'
sourceCompatibility = 1.6
targetCompatibility = 1.6

kotlin.experimental.coroutines "enable"

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testCompile "junit:junit:$junit_version"
}

repositories {
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://dl.bintray.com/devexperts/Maven/" }
}

tasks.withType(Test) {
testLogging {
showStandardStreams = true
events "passed", "failed"
}
def stressTest = project.properties['stressTest']
if (stressTest != null) systemProperties['stressTest'] = stressTest
}
37 changes: 37 additions & 0 deletions gradle/compile-native.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apply plugin: 'konan'

repositories {
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
}

def libraryName = project.name
def testProgramName = libraryName + "-test"

konanArtifacts {
library(libraryName, targets: ["ios_arm64", "ios_x64", "macos_x64"]) {
artifactName libraryName.replace('-', '_')
enableMultiplatform true
dependencies {
"artifact$libraryName" "org.jetbrains.kotlinx:atomicfu-native:$atomicFU_version"
}
}
// TODO: THIS IS A WORKAROUND: Cannot do tests together with publishing in Kotlin/Native
if (!rootProject.properties["publish"]) {
program(testProgramName, targets: ["macos_x64"]) {
srcDir 'src/test/kotlin'
commonSourceSet 'test'
libraries {
artifact libraryName
}
extraOpts '-tr'
}
}
}

task test(dependsOn: run)

// TODO: THIS IS A WORKAROUND: Cannot do tests together with publishing in Kotlin/Native
if (rootProject.properties["publish"]) {
publishToMavenLocal.dependsOn(build)
}
85 changes: 39 additions & 46 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@
rootProject.name = 'kotlinx.coroutines'

include 'kotlinx-coroutines-core-common'

include 'kotlinx-coroutines-core'
include 'kotlinx-coroutines-io'

include 'kotlinx-coroutines-guava'
include 'kotlinx-coroutines-jdk8'
include 'kotlinx-coroutines-nio'
include 'kotlinx-coroutines-quasar'

include 'kotlinx-coroutines-reactive'
include 'kotlinx-coroutines-reactor'
include 'kotlinx-coroutines-rx1'
include 'kotlinx-coroutines-rx2'
include 'kotlinx-coroutines-rx-example'

include 'kotlinx-coroutines-android'
include 'kotlinx-coroutines-javafx'
include 'kotlinx-coroutines-swing'

include 'kotlinx-coroutines-core-js'
include 'js-stub'
include 'example-frontend-js'

include 'benchmarks'
include 'knit'
include 'site'

project(':kotlinx-coroutines-core-common').projectDir = file('common/kotlinx-coroutines-core-common')
project(':kotlinx-coroutines-core').projectDir = file('core/kotlinx-coroutines-core')
project(':kotlinx-coroutines-io').projectDir = file('core/kotlinx-coroutines-io')
project(':kotlinx-coroutines-guava').projectDir = file('integration/kotlinx-coroutines-guava')
project(':kotlinx-coroutines-jdk8').projectDir = file('integration/kotlinx-coroutines-jdk8')
project(':kotlinx-coroutines-nio').projectDir = file('integration/kotlinx-coroutines-nio')
project(':kotlinx-coroutines-quasar').projectDir = file('integration/kotlinx-coroutines-quasar')
project(':kotlinx-coroutines-reactive').projectDir = file('reactive/kotlinx-coroutines-reactive')
project(':kotlinx-coroutines-reactor').projectDir = file('reactive/kotlinx-coroutines-reactor')
project(':kotlinx-coroutines-rx1').projectDir = file('reactive/kotlinx-coroutines-rx1')
project(':kotlinx-coroutines-rx2').projectDir = file('reactive/kotlinx-coroutines-rx2')
project(':kotlinx-coroutines-rx-example').projectDir = file('reactive/kotlinx-coroutines-rx-example')
project(':kotlinx-coroutines-android').projectDir = file('ui/kotlinx-coroutines-android')
project(':kotlinx-coroutines-javafx').projectDir = file('ui/kotlinx-coroutines-javafx')
project(':kotlinx-coroutines-swing').projectDir = file('ui/kotlinx-coroutines-swing')
project(':kotlinx-coroutines-core-js').projectDir = file('js/kotlinx-coroutines-core-js')
project(':js-stub').projectDir = file('js/js-stub')
project(':example-frontend-js').projectDir = file('js/example-frontend-js')
def module(String path) {
int i = path.lastIndexOf('/')
def name = path.substring(i + 1)
include(name)
project(":$name").projectDir = file(path)
}

// ---------------------------

include('benchmarks')
include('knit')
include('site')

module('common/kotlinx-coroutines-core-common')

module('core/kotlinx-coroutines-core')
module('core/kotlinx-coroutines-io')

module('integration/kotlinx-coroutines-guava')
module('integration/kotlinx-coroutines-jdk8')
module('integration/kotlinx-coroutines-nio')
module('integration/kotlinx-coroutines-quasar')

module('reactive/kotlinx-coroutines-reactive')
module('reactive/kotlinx-coroutines-reactor')
module('reactive/kotlinx-coroutines-rx1')
module('reactive/kotlinx-coroutines-rx2')
module('reactive/kotlinx-coroutines-rx-example')

module('ui/kotlinx-coroutines-android')
module('ui/kotlinx-coroutines-javafx')
module('ui/kotlinx-coroutines-swing')

module('js/kotlinx-coroutines-core-js')
module('js/js-stub')
module('js/example-frontend-js')

//module('native/kotlinx-coroutines-core-native')

0 comments on commit 3145290

Please sign in to comment.