forked from Kotlin/kotlinx.coroutines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
193 lines (157 loc) · 6.29 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
allprojects {
group = 'org.jetbrains.kotlinx'
def deployVersion = properties['DeployVersion']
if (deployVersion != null) version = deployVersion
}
buildscript {
if (rootProject.properties['kotlinSnapshot'] != null) {
ext.kotlin_version = '1.2-SNAPSHOT'
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
repositories {
jcenter()
maven { url "http://kotlin.bintray.com/kotlinx" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_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"
}
}
// 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"
return "jvm"
}
static def platformLib(base, platform) {
if (platform == "jvm") return base
return "$base-$platform"
}
configure(subprojects.findAll { !sourceless.contains(it.name) }) {
def platform = platformOf(it)
apply plugin: "kotlin-platform-$platform"
if (platform == "jvm") {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
kotlin.experimental.coroutines "enable"
if (platform == "js") {
tasks.withType(compileKotlin2Js.getClass()) {
kotlinOptions {
moduleKind = "umd"
sourceMap = true
metaInfo = true
// drop -js suffix from outputFile
def baseName = project.name - "-js"
outputFile = new File(outputFile.parent, baseName + ".js")
}
}
}
tasks.withType(Test) {
testLogging {
showStandardStreams = true
events "passed", "failed"
}
def stressTest = project.properties['stressTest']
if (stressTest != null) systemProperties['stressTest'] = stressTest
}
repositories {
jcenter()
maven { url "http://kotlin.bintray.com/kotlinx" }
maven { url "https://dl.bintray.com/devexperts/Maven/" }
}
def kotlin_stdlib = platformLib("kotlin-stdlib", platform)
def kotlin_test = platformLib("kotlin-test", platform)
dependencies {
compile "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
testCompile "org.jetbrains.kotlin:$kotlin_test:$kotlin_version"
}
if (platform == "common") {
dependencies {
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
}
}
if (platform == "jvm") {
dependencies {
testCompile "junit:junit:$junit_version"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}
}
}
// --------------- 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 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 ---------------
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
}
}
// main deployment task
task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
apply plugin: 'base'
clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }