Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 1 | allprojects { |
| 2 | group = 'org.jetbrains.kotlinx' |
Roman Elizarov | ba5e5da | 2017-10-27 14:02:55 +0300 | [diff] [blame] | 3 | def deployVersion = properties['DeployVersion'] |
| 4 | if (deployVersion != null) version = deployVersion |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 5 | } |
| 6 | |
| 7 | buildscript { |
Roman Elizarov | 1f6b44d | 2017-10-26 17:51:52 +0300 | [diff] [blame] | 8 | if (System.properties['kotlinSnapshot'] != null) { |
Roman Elizarov | dadd50c | 2017-12-21 17:34:12 +0300 | [diff] [blame] | 9 | ext.kotlin_version = '1.2-SNAPSHOT' |
Roman Elizarov | 1f6b44d | 2017-10-26 17:51:52 +0300 | [diff] [blame] | 10 | repositories { |
| 11 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 12 | } |
| 13 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 14 | repositories { |
| 15 | jcenter() |
Roman Elizarov | 4d84a78 | 2017-11-30 13:23:40 +0300 | [diff] [blame] | 16 | maven { url "http://kotlin.bintray.com/kotlinx" } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 17 | } |
| 18 | dependencies { |
| 19 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| 20 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" |
| 21 | classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version" |
| 22 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | // --------------- pom configuration --------------- |
| 27 | |
| 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 | } |
| 44 | |
| 45 | scm { |
| 46 | url "https://github.com/Kotlin/kotlinx.coroutines" |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | // --------------- Configure sub-projects with Kotlin sources --------------- |
| 51 | |
| 52 | def sourceless = ['site'] |
| 53 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 54 | static def platformOf(project) { |
| 55 | if (project.name.endsWith("-common")) return "common" |
| 56 | if (project.name.endsWith("-js")) return "js" |
| 57 | return "jvm" |
| 58 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 59 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 60 | static def platformLib(base, platform) { |
| 61 | if (platform == "jvm") return base |
| 62 | return "$base-$platform" |
| 63 | } |
| 64 | |
| 65 | configure(subprojects.findAll { !sourceless.contains(it.name) }) { |
| 66 | def platform = platformOf(it) |
| 67 | apply plugin: "kotlin-platform-$platform" |
| 68 | |
| 69 | if (platform == "jvm") { |
| 70 | sourceCompatibility = 1.6 |
| 71 | targetCompatibility = 1.6 |
| 72 | |
| 73 | tasks.withType(JavaCompile) { |
| 74 | options.encoding = 'UTF-8' |
| 75 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 76 | } |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 77 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 78 | kotlin.experimental.coroutines "enable" |
| 79 | |
| 80 | tasks.withType(Test) { |
| 81 | testLogging.showStandardStreams = true |
Roman Elizarov | 94c3168 | 2017-10-27 12:20:39 +0300 | [diff] [blame] | 82 | def stressTest = project.properties['stressTest'] |
Roman Elizarov | 6f5bd3f | 2017-10-26 18:15:00 +0300 | [diff] [blame] | 83 | if (stressTest != null) systemProperties['stressTest'] = stressTest |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | repositories { |
| 87 | jcenter() |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 88 | maven { url "http://kotlin.bintray.com/kotlinx" } |
| 89 | maven { url "https://dl.bintray.com/devexperts/Maven/" } |
| 90 | } |
| 91 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 92 | def kotlin_stdlib = platformLib("kotlin-stdlib", platform) |
| 93 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 94 | dependencies { |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 95 | compile "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 96 | testCompile "junit:junit:$junit_version" |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // --------------- Configure sub-projects that are part of the library --------------- |
| 101 | |
| 102 | def internal = sourceless + ['benchmarks', 'knit'] |
| 103 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 104 | // configure atomicfu for JVM modules |
| 105 | configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) { |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 106 | apply plugin: 'kotlinx-atomicfu' |
| 107 | |
| 108 | dependencies { |
| 109 | compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version" |
| 110 | testCompile "org.jetbrains.kotlinx:atomicfu:$atomicFU_version" |
| 111 | } |
| 112 | |
| 113 | atomicFU { |
| 114 | inputFiles = sourceSets.main.output.classesDirs |
| 115 | outputDir = file("$buildDir/classes-atomicfu/main") |
| 116 | classPath = sourceSets.main.runtimeClasspath |
| 117 | } |
| 118 | |
| 119 | jar { |
| 120 | mainSpec.sourcePaths.clear() // hack to clear existing paths |
| 121 | from files(atomicFU.outputs, sourceSets.main.output.resourcesDir) |
| 122 | } |
| 123 | |
| 124 | test { |
| 125 | classpath = files(configurations.testRuntime, atomicFU.outputs, sourceSets.test.output.classesDirs, |
| 126 | sourceSets.main.output.resourcesDir) |
| 127 | } |
| 128 | } |
| 129 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 130 | // configure dependencies on core |
| 131 | configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) { |
| 132 | def platform = platformOf(it) |
| 133 | def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
| 134 | |
| 135 | if (it.name == coroutines_core) { |
| 136 | dependencies { |
| 137 | expectedBy project(':kotlinx-coroutines-core-common') |
| 138 | } |
| 139 | } else { |
| 140 | dependencies { |
| 141 | compile project(":$coroutines_core") |
| 142 | //the only way IDEA can resolve test classes |
| 143 | testCompile project(":$coroutines_core").sourceSets.test.output |
| 144 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
| 148 | // --------------- Configure sub-projects that are published --------------- |
| 149 | |
| 150 | def unpublished = internal + 'kotlinx-coroutines-rx-example' |
| 151 | |
| 152 | def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/" |
| 153 | def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list" |
| 154 | |
| 155 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 156 | def platform = platformOf(it) |
| 157 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 158 | apply plugin: 'maven' |
| 159 | apply plugin: 'maven-publish' |
| 160 | apply plugin: 'org.jetbrains.dokka' |
| 161 | apply plugin: 'com.jfrog.bintray' |
| 162 | |
| 163 | dokka { |
| 164 | outputFormat = 'kotlin-website' |
| 165 | } |
| 166 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 167 | if (platform == "jvm") { |
| 168 | // real xxx-javadoc.jar for JVM |
| 169 | task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { |
| 170 | outputFormat = 'javadoc' |
| 171 | outputDirectory = "$buildDir/javadoc" |
| 172 | } |
| 173 | |
| 174 | task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { |
| 175 | classifier = 'javadoc' |
| 176 | from "$buildDir/javadoc" |
| 177 | } |
| 178 | } else { |
| 179 | // empty xxx-javadoc.jar |
| 180 | task javadocJar(type: Jar) { |
| 181 | classifier = 'javadoc' |
| 182 | from "$buildDir/javadoc" // would not exist |
| 183 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) { |
| 187 | jdkVersion = 8 |
| 188 | includes = ['README.md'] |
| 189 | linkMapping { |
Roman Elizarov | 8fc0075 | 2017-10-27 13:35:36 +0300 | [diff] [blame] | 190 | def relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath()) |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 191 | dir = "$projectDir/src/main/kotlin" |
Roman Elizarov | 8fc0075 | 2017-10-27 13:35:36 +0300 | [diff] [blame] | 192 | url = "http://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath/src/main/kotlin" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 193 | suffix = "#L" |
| 194 | } |
| 195 | } |
| 196 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 197 | task sourcesJar(type: Jar, dependsOn: classes) { |
| 198 | classifier = 'sources' |
| 199 | from sourceSets.main.allSource |
| 200 | } |
| 201 | |
| 202 | publishing { |
| 203 | publications { |
| 204 | maven(MavenPublication) { |
Roman Elizarov | eb98bc8 | 2017-10-27 14:57:08 +0300 | [diff] [blame] | 205 | from components.java |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 206 | artifact javadocJar |
| 207 | artifact sourcesJar |
| 208 | pom.withXml { |
| 209 | def root = asNode() |
| 210 | root.appendNode('name', project.name) |
| 211 | root.appendNode('description', 'Coroutines support libraries for Kotlin') |
| 212 | root.appendNode('url', 'https://github.com/Kotlin/kotlinx.coroutines') |
| 213 | root.children().last() + pomConfig |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | bintray { |
| 220 | user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') |
| 221 | key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') |
| 222 | publications = ['maven'] |
| 223 | pkg { |
| 224 | userOrg = 'kotlin' |
| 225 | repo = 'kotlinx' |
| 226 | name = 'kotlinx.coroutines' |
| 227 | version { |
| 228 | name = project.version |
| 229 | vcsTag = project.version |
| 230 | released = new Date() |
| 231 | } |
| 232 | } |
| 233 | } |
Roman Elizarov | ba5e5da | 2017-10-27 14:02:55 +0300 | [diff] [blame] | 234 | |
| 235 | bintrayUpload.doLast { |
| 236 | println("Uploaded $project.name version $project.version") |
| 237 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 238 | } |
| 239 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame^] | 240 | configure(subprojects.findAll { !unpublished.contains(it.name) && it.name != 'kotlinx-coroutines-core-common' }) { |
| 241 | def platform = platformOf(it) |
| 242 | def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
| 243 | |
| 244 | dokka.dependsOn project(":$coroutines_core").dokka |
| 245 | if (platform == "jvm") { |
| 246 | dokkaJavadoc.dependsOn project(":$coroutines_core").dokka |
| 247 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 248 | |
| 249 | tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) { |
| 250 | externalDocumentationLink { |
| 251 | url = new URL(core_docs_url) |
| 252 | packageListUrl = new URL("file://$core_docs_file") |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | apply plugin: 'base' |
| 258 | |
| 259 | clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } |