| /* |
| * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| */ |
| |
| buildscript { |
| ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null |
| if (useKotlinSnapshot) { |
| ext.kotlin_version = '1.2-SNAPSHOT' |
| repositories { |
| maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| } |
| } |
| repositories { |
| jcenter() |
| 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/" } |
| } |
| configurations.classpath { |
| resolutionStrategy { |
| eachDependency { DependencyResolveDetails details -> |
| if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name != 'kotlin-native-gradle-plugin') { |
| // fix version of all dependencies from org.jetbrains.kotlin group |
| // even when other dependencies require other versions indirectly, |
| // except kotlin-native, which has its own pre-release versioning |
| details.useVersion kotlin_version |
| } |
| } |
| } |
| } |
| 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" |
| classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" |
| |
| // JMH plugins |
| classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2" |
| classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.7" |
| classpath "net.ltgt.gradle:gradle-apt-plugin:0.10" |
| } |
| } |
| |
| allprojects { |
| def deployVersion = properties['DeployVersion'] |
| if (deployVersion != null) version = deployVersion |
| if (useKotlinSnapshot) { |
| kotlin_version = '1.2-SNAPSHOT' |
| } |
| |
| repositories { |
| jcenter() |
| maven { url "https://kotlin.bintray.com/kotlin-dev" } |
| maven { url "https://kotlin.bintray.com/kotlinx" } |
| } |
| } |
| |
| |
| // Report Kotlin compiler version when building project |
| println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION") |
| |
| // --------------- Configure sub-projects with Kotlin sources --------------- |
| |
| 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" |
| } |
| |
| static def platformLib(base, platform) { |
| if (platform == "jvm") return base |
| return "$base-$platform" |
| } |
| |
| subprojects { |
| if (useKotlinSnapshot) { |
| repositories { |
| maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| } |
| } |
| configurations.all { |
| resolutionStrategy { |
| eachDependency { DependencyResolveDetails details -> |
| if (details.requested.group == 'org.jetbrains.kotlin') { |
| details.useVersion kotlin_version |
| } |
| } |
| } |
| } |
| } |
| |
| configure(subprojects.findAll { !sourceless.contains(it.name) }) { |
| def platform = platformOf(it) |
| apply from: rootProject.file("gradle/compile-${platform}.gradle") |
| } |
| |
| // --------------- Configure sub-projects that are part of the library --------------- |
| |
| def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'binary-compatibility-validator'] |
| |
| // Reconfigure source sets to avoid long "src/main/kotlin/fqn" |
| configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) { |
| def projectName = it.name |
| sourceSets { |
| main.kotlin.srcDirs = ['src'] |
| test.kotlin.srcDirs = ['test'] |
| // todo: do we still need this workaround? |
| if (!projectName.endsWith("-native")) { |
| main.resources.srcDirs = ['resources'] |
| test.resources.srcDirs = ['test-resources'] |
| } |
| } |
| } |
| |
| // 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 |
| configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) { |
| def platform = platformOf(it) |
| def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
| |
| if (it.name == coroutines_core) { |
| dependencies { |
| expectedBy project(':kotlinx-coroutines-core-common') |
| } |
| } else { |
| dependencies { |
| compile project(":$coroutines_core") |
| //the only way IDEA can resolve test classes |
| testCompile project(":$coroutines_core").sourceSets.test.output |
| } |
| } |
| } |
| |
| // --------------- Configure sub-projects that are published --------------- |
| |
| // todo: native is not published yet |
| def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js'] |
| |
| 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" |
| |
| configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
| apply from: rootProject.file('gradle/dokka.gradle') |
| apply from: rootProject.file('gradle/publish-bintray.gradle') |
| } |
| |
| configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
| def platform = platformOf(it) |
| def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
| |
| if (it.name != coroutines_core) { |
| dokka.dependsOn project(":$coroutines_core").dokka |
| |
| tasks.withType(dokka.getClass()) { |
| externalDocumentationLink { |
| url = new URL(core_docs_url) |
| packageListUrl = new URL("file://$core_docs_file") |
| } |
| } |
| } |
| |
| if (platform == "jvm") { |
| dokkaJavadoc.dependsOn project(":$coroutines_core").dokka |
| // dump declarations from main JVM module for binary-compatibility-validator |
| compileKotlin { |
| kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"] |
| } |
| } |
| } |
| |
| // main deployment task |
| task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true)) |
| |
| apply plugin: 'base' |
| |
| clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } |