1
1
/*
2
- * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2
+ * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
+ import org.jetbrains.kotlin.konan.target.HostManager
5
+
6
+ apply from : rootProject. file(" gradle/experimental.gradle" )
7
+
8
+ def rootModule = " kotlinx.coroutines"
9
+ def coreModule = " kotlinx-coroutines-core"
10
+ // Not applicable for Kotlin plugin
11
+ def sourceless = [' kotlinx.coroutines' , ' site' ]
12
+ def internal = sourceless + [' benchmarks' , ' knit' , ' js-stub' , ' stdlib-stubs' , ' binary-compatibility-validator' ]
13
+ // Not published
14
+ def unpublished = internal + [' kotlinx-coroutines-rx-example' , ' example-frontend-js' , ' android-unit-tests' ]
15
+
16
+ static def platformOf (project ) {
17
+ def name = project. name
18
+ if (name. endsWith(" -js" )) return " js"
19
+ if (name. endsWith(" -common" ) || name. endsWith(" -native" )) {
20
+ throw IllegalStateException (" $name platform is not supported" )
21
+ }
22
+ return " jvm"
23
+ }
4
24
5
25
buildscript {
6
26
ext. useKotlinSnapshot = rootProject. properties[' kotlinSnapshot' ] != null
@@ -19,22 +39,10 @@ buildscript {
19
39
maven { url " https://jetbrains.bintray.com/kotlin-native-dependencies" }
20
40
maven { url " https://plugins.gradle.org/m2/" }
21
41
}
22
- configurations. classpath {
23
- resolutionStrategy {
24
- eachDependency { DependencyResolveDetails details ->
25
- if (details. requested. group == ' org.jetbrains.kotlin' && details. requested. name != ' kotlin-native-gradle-plugin' ) {
26
- // fix version of all dependencies from org.jetbrains.kotlin group
27
- // even when other dependencies require other versions indirectly,
28
- // except kotlin-native, which has its own pre-release versioning
29
- details. useVersion kotlin_version
30
- }
31
- }
32
- }
33
- }
42
+
34
43
dependencies {
35
44
classpath " org.jfrog.buildinfo:build-info-extractor-gradle:$artifactory_plugin_version "
36
45
classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
37
- classpath " org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version "
38
46
classpath " org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version "
39
47
classpath " org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version "
40
48
classpath " com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version "
@@ -48,19 +56,26 @@ buildscript {
48
56
}
49
57
50
58
allprojects {
59
+ // the only place where HostManager could be instantiated
60
+ project. ext. hostManager = new HostManager ()
61
+ }
62
+
63
+ allprojects {
64
+ apply plugin : ' kotlinx-atomicfu'
65
+
51
66
def deployVersion = properties[' DeployVersion' ]
52
67
if (deployVersion != null ) version = deployVersion
53
68
if (useKotlinSnapshot) {
54
69
kotlin_version = ' 1.2-SNAPSHOT'
55
70
}
56
71
57
- def name = it. name
72
+ def projectName = it. name
58
73
repositories {
59
74
/*
60
75
* google should be first in the repository list because some of the play services
61
76
* transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution
62
77
*/
63
- if (name == " kotlinx-coroutines-play-services" ) {
78
+ if (projectName == " kotlinx-coroutines-play-services" ) {
64
79
google()
65
80
}
66
81
jcenter()
@@ -69,111 +84,72 @@ allprojects {
69
84
maven { url " https://kotlin.bintray.com/kotlin-eap" }
70
85
maven { url " https://kotlin.bintray.com/kotlinx" }
71
86
}
72
- }
73
87
88
+ if (projectName == rootModule || projectName == coreModule) return
74
89
75
- // Report Kotlin compiler version when building project
76
- println (" Using Kotlin compiler version: $org . jetbrains . kotlin . config . KotlinCompilerVersion . VERSION " )
90
+ // Add dependency to core source sets. Core is configured in kx-core/build.gradle
91
+ evaluationDependsOn(" :$coreModule " )
92
+ if (sourceless. contains(projectName)) return
77
93
78
- // --------------- Configure sub-projects with Kotlin sources ---------------
94
+ def platform = platformOf(it)
95
+ apply from : rootProject. file(" gradle/compile-${ platform} .gradle" )
79
96
80
- def sourceless = [' site' ]
81
97
82
- static def platformOf (project ) {
83
- if (project. name. endsWith(" -common" )) return " common"
84
- if (project. name. endsWith(" -js" )) return " js"
85
- if (project. name. endsWith(" -native" )) return " native"
86
- return " jvm"
87
- }
98
+ dependencies {
99
+ // See comment below for rationale, it will be replaced with "project" dependency
100
+ compile " org.jetbrains.kotlinx:kotlinx-coroutines-core:$version "
101
+ compileOnly " org.jetbrains.kotlinx:atomicfu:$atomicFU_version "
88
102
89
- static def platformLib (base , platform ) {
90
- if (platform == " jvm" ) return base
91
- return " $base -$platform "
92
- }
103
+ // the only way IDEA can resolve test classes
104
+ testCompile project(" :$coreModule " ). kotlin. targets. jvm. compilations. test. output. allOutputs
105
+ }
93
106
94
- subprojects {
95
- if (useKotlinSnapshot) {
96
- repositories {
97
- maven { url " https://oss.sonatype.org/content/repositories/snapshots " }
98
- }
107
+ tasks . withType( org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile ) . all {
108
+ kotlinOptions . freeCompilerArgs + = experimentalAnnotations . collect { " -Xuse-experimental= " + it }
109
+ kotlinOptions . freeCompilerArgs + = " -progressive "
110
+ // Binary compatibility support
111
+ kotlinOptions . freeCompilerArgs + = [ " -Xdump-declarations-to= ${ buildDir } /visibilities.json " ]
99
112
}
113
+ }
114
+
115
+ /*
116
+ * Hack to trick nmpp plugin: we are renaming artifacts in order to provide backward compatibility for dependencies,
117
+ * but publishing plugin does not re-read artifact names for kotlin-jvm projects, so renaming is not applied in pom files
118
+ * for JVM-only projects.
119
+ *
120
+ * We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it
121
+ * to have out "project" dependency back.
122
+ */
123
+ configure(subprojects. findAll { it. name != coreModule && it. name != rootModule }) {
100
124
configurations. all {
101
- resolutionStrategy {
102
- eachDependency { DependencyResolveDetails details ->
103
- if (details. requested. group == ' org.jetbrains.kotlin' ) {
104
- details. useVersion kotlin_version
105
- }
106
- }
125
+ resolutionStrategy. dependencySubstitution {
126
+ substitute module(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$version " ) with project(' :kotlinx-coroutines-core' )
107
127
}
108
128
}
109
129
}
110
130
111
- configure(subprojects. findAll { ! sourceless. contains(it. name) }) {
112
- def platform = platformOf(it)
113
- apply from : rootProject. file(" gradle/compile-${ platform} .gradle" )
114
- }
115
-
116
- // --------------- Configure sub-projects that are part of the library ---------------
117
-
118
- def internal = sourceless + [' benchmarks' , ' knit' , ' js-stub' , ' stdlib-stubs' , ' binary-compatibility-validator' ]
119
-
120
- // Reconfigure source sets to avoid long "src/main/kotlin/fqn"
121
- configure(subprojects. findAll { ! it. name. contains(sourceless) && it. name != " benchmarks" }) {
122
- def projectName = it. name
131
+ // Redefine source sets because we are not using 'kotlin/main/fqn' folder convention
132
+ configure(subprojects. findAll { ! sourceless. contains(it. name) && it. name != " benchmarks" && it. name != coreModule }) {
123
133
sourceSets {
124
134
main. kotlin. srcDirs = [' src' ]
125
135
test. kotlin. srcDirs = [' test' ]
126
- // todo: do we still need this workaround?
127
- if (! projectName. endsWith(" -native" )) {
128
- main. resources. srcDirs = [' resources' ]
129
- test. resources. srcDirs = [' test-resources' ]
130
- }
131
- }
132
- }
133
-
134
- // configure atomicfu
135
- configure(subprojects. findAll { ! internal. contains(it. name) }) {
136
- def platform = platformOf(it)
137
- apply from : rootProject. file(" gradle/atomicfu-${ platform} .gradle" )
138
- }
139
-
140
- // configure dependencies on core
141
- configure(subprojects. findAll { ! internal. contains(it. name) && it. name != ' kotlinx-coroutines-core-common' }) {
142
- def platform = platformOf(it)
143
- def coroutines_core = platformLib(" kotlinx-coroutines-core" , platform)
136
+ main. resources. srcDirs = [' resources' ]
137
+ test. resources. srcDirs = [' test-resources' ]
144
138
145
- if (it. name == coroutines_core) {
146
- dependencies {
147
- expectedBy project(' :kotlinx-coroutines-core-common' )
148
- }
149
- } else {
150
- dependencies {
151
- compile project(" :$coroutines_core " )
152
- // the only way IDEA can resolve test classes
153
- testCompile project(" :$coroutines_core " ). sourceSets. test. output
154
- }
155
139
}
156
140
}
157
141
158
- // --------------- Configure sub-projects that are published ---------------
159
-
160
- def unpublished = internal + [' kotlinx-coroutines-rx-example' , ' example-frontend-js' , ' android-unit-tests' ]
161
-
162
- def core_docs_url = " https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
163
- def core_docs_file = " $projectDir /core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
142
+ def core_docs_url = " https://kotlin.github.io/kotlinx.coroutines/$coreModule /"
143
+ def core_docs_file = " $projectDir /kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
164
144
165
145
configure(subprojects. findAll { ! unpublished. contains(it. name) }) {
166
146
apply from : rootProject. file(' gradle/dokka.gradle' )
167
147
apply from : rootProject. file(' gradle/publish-bintray.gradle' )
168
148
}
169
149
170
150
configure(subprojects. findAll { ! unpublished. contains(it. name) }) {
171
- def platform = platformOf(it)
172
- def coroutines_core = platformLib(" kotlinx-coroutines-core" , platform)
173
-
174
- if (it. name != coroutines_core) {
175
- dokka. dependsOn project(" :$coroutines_core " ). dokka
176
-
151
+ if (it. name != coreModule) {
152
+ dokka. dependsOn project(" :$coreModule " ). dokka
177
153
tasks. withType(dokka. getClass()) {
178
154
externalDocumentationLink {
179
155
url = new URL (core_docs_url)
@@ -182,27 +158,16 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) {
182
158
}
183
159
}
184
160
185
- if (platform == " jvm" ) {
186
- dokkaJavadoc. dependsOn project(" :$coroutines_core " ). dokka
187
- // dump declarations from main JVM module for binary-compatibility-validator
188
- compileKotlin {
189
- kotlinOptions. freeCompilerArgs + = [" -Xdump-declarations-to=${ buildDir} /visibilities.json" ]
190
- }
161
+ if (platformOf(it) == " jvm" ) {
162
+ dokkaJavadoc. dependsOn project(" :$coreModule " ). dokka
191
163
}
164
+ }
192
165
193
166
194
- tasks. withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile ). all {
195
- kotlinOptions. freeCompilerArgs + = [" -Xuse-experimental=kotlin.Experimental" ,
196
- " -Xuse-experimental=kotlin.experimental.ExperimentalTypeInference" ,
197
- " -Xuse-experimental=kotlin.ExperimentalMultiplatform" ,
198
- " -Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi" ,
199
- " -Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi" ,
200
- " -Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi" ,
201
- " -progressive" ]
202
- }
203
- }
167
+ // Report Kotlin compiler version when building project
168
+ println (" Using Kotlin compiler version: $org . jetbrains . kotlin . config . KotlinCompilerVersion . VERSION " )
204
169
205
- // main deployment task
170
+ // --------------- Configure sub-projects that are published ---------------
206
171
task deploy (dependsOn : getTasksByName(" bintrayUpload" , true ) + getTasksByName(" publishNpm" , true ))
207
172
208
173
apply plugin : ' base'
0 commit comments