2
2
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
+ import org.jetbrains.kotlin.gradle.dsl.*
5
6
6
7
buildscript {
7
8
@@ -14,40 +15,41 @@ buildscript {
14
15
* Additionally, mavenLocal and Sonatype snapshots are added to repository list and stress tests are disabled.
15
16
* DO NOT change the name of these properties without adapting kotlinx.train build chain.
16
17
*/
17
- def prop = rootProject. properties[' build_snapshot_train' ]
18
- ext . build_snapshot_train = prop != null && prop != " "
18
+ extra[ " build_snapshot_train " ] = rootProject.properties[" build_snapshot_train" ]. let { it != null && it != " " }
19
+ val build_snapshot_train: Boolean by extra
19
20
if (build_snapshot_train) {
20
- ext. kotlin_version = rootProject. properties[' kotlin_snapshot_version' ]
21
+ extra[" kotlin_version" ] = rootProject.properties[" kotlin_snapshot_version" ]
22
+ val kotlin_version: String? by extra
21
23
if (kotlin_version == null ) {
22
- throw new IllegalArgumentException (" 'kotlin_snapshot_version' should be defined when building with snapshot compiler" )
24
+ throw IllegalArgumentException (" 'kotlin_snapshot_version' should be defined when building with snapshot compiler" )
23
25
}
24
26
}
25
- ext . native_targets_enabled = rootProject. properties[' disable_native_targets' ] == null
27
+ extra[ " native_targets_enabled" ] = rootProject.properties[" disable_native_targets" ] == null
26
28
27
29
// Determine if any project dependency is using a snapshot version
28
- ext. using_snapshot_version = build_snapshot_train
29
- rootProject. properties. each { key , value ->
30
- if (key. endsWith(" _version" ) && value instanceof String && value. endsWith(" -SNAPSHOT" )) {
30
+ extra[" using_snapshot_version" ] = build_snapshot_train
31
+
32
+ rootProject.properties.forEach { key, value ->
33
+ if (key.endsWith(" _version" ) && value is String && value.endsWith(" -SNAPSHOT" )) {
31
34
println (" NOTE: USING SNAPSHOT VERSION: $key =$value " )
32
- ext . using_snapshot_version = true
35
+ extra[ " using_snapshot_version" ] = true
33
36
}
34
37
}
35
38
36
- if (using_snapshot_version ) {
39
+ if (build_snapshot_train ) {
37
40
repositories {
38
41
mavenLocal()
39
- maven { url " https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
42
+ maven( url = " https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" )
40
43
}
41
44
}
42
-
43
45
}
44
46
45
47
plugins {
46
- id " org.jetbrains.kotlin.jvm" version " $kotlin_version "
48
+ id( " org.jetbrains.kotlin.jvm" ) version " ${extra[ " kotlin_version" ]} "
47
49
}
48
50
49
51
repositories {
50
- maven { url " https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
52
+ maven( url = " https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" )
51
53
mavenLocal()
52
54
mavenCentral()
53
55
}
58
60
}
59
61
60
62
dependencies {
61
- testImplementation " org.jetbrains.kotlin:kotlin-test:$kotlin_version "
62
- testImplementation " org.ow2.asm:asm:$asm_version "
63
- implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk8"
63
+ testImplementation( " org.jetbrains.kotlin:kotlin-test:${extra[ " kotlin_version" ]} " )
64
+ testImplementation( " org.ow2.asm:asm:${rootProject.properties[ " asm_version" ]} " )
65
+ implementation( " org.jetbrains.kotlin:kotlin-stdlib-jdk8" )
64
66
}
65
67
66
68
sourceSets {
@@ -71,8 +73,8 @@ sourceSets {
71
73
runtimeClasspath + = sourceSets.test.runtimeClasspath
72
74
73
75
dependencies {
74
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
75
- implementation ' com.google.guava:guava:31.1-jre'
76
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.properties[ " coroutines_version" ]} " )
77
+ implementation( " com.google.guava:guava:31.1-jre" )
76
78
}
77
79
}
78
80
// Checks correctness of Maven publication (JAR resources) and absence of atomicfu symbols
@@ -82,8 +84,8 @@ sourceSets {
82
84
runtimeClasspath + = sourceSets.test.runtimeClasspath
83
85
84
86
dependencies {
85
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
86
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version "
87
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.properties[ " coroutines_version" ]} " )
88
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-android:${rootProject.properties[ " coroutines_version" ]} " )
87
89
}
88
90
}
89
91
// Checks that kotlinx-coroutines-debug can be used as -javaagent parameter
@@ -93,8 +95,8 @@ sourceSets {
93
95
runtimeClasspath + = sourceSets.test.runtimeClasspath
94
96
95
97
dependencies {
96
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
97
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version "
98
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.properties[ " coroutines_version" ]} " )
99
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-debug:${rootProject.properties[ " coroutines_version" ]} " )
98
100
}
99
101
}
100
102
@@ -105,8 +107,8 @@ sourceSets {
105
107
runtimeClasspath + = sourceSets.test.runtimeClasspath
106
108
107
109
dependencies {
108
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
109
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version "
110
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.properties[ " coroutines_version" ]} " )
111
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-debug:${rootProject.properties[ " coroutines_version" ]} " )
110
112
}
111
113
}
112
114
@@ -117,7 +119,7 @@ sourceSets {
117
119
runtimeClasspath + = sourceSets.test.runtimeClasspath
118
120
119
121
dependencies {
120
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
122
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.properties[ " coroutines_version" ]} " )
121
123
}
122
124
}
123
125
}
@@ -128,39 +130,39 @@ compileDebugAgentTestKotlin {
128
130
}
129
131
}
130
132
131
- task jvmCoreTest ( type : Test ) {
132
- environment " version" , coroutines_version
133
- def sourceSet = sourceSets. jvmCoreTest
133
+ tasks.create< Test >( " jvmCoreTest " ) {
134
+ environment( " version" , rootProject.properties[ " coroutines_version" ])
135
+ val sourceSet = sourceSets.jvmCoreTest
134
136
testClassesDirs = sourceSet.output.classesDirs
135
137
classpath = sourceSet.runtimeClasspath
136
138
}
137
139
138
- task mavenTest ( type : Test ) {
139
- environment " version" , coroutines_version
140
- def sourceSet = sourceSets. mavenTest
140
+ tasks.create< Test >( " mavenTest " ) {
141
+ environment( " version" , rootProject.properties[ " coroutines_version" ])
142
+ val sourceSet = sourceSets.mavenTest
141
143
testClassesDirs = sourceSet.output.classesDirs
142
144
classpath = sourceSet.runtimeClasspath
143
145
}
144
146
145
- task debugAgentTest ( type : Test ) {
146
- def sourceSet = sourceSets. debugAgentTest
147
- def coroutinesDebugJar = sourceSet. runtimeClasspath. filter {it. name == " kotlinx-coroutines-debug-${ coroutines_version} .jar" }. singleFile
148
- jvmArgs (' -javaagent:' + coroutinesDebugJar)
147
+ tasks.create< Test >( " debugAgentTest " ) {
148
+ val sourceSet = sourceSets.debugAgentTest
149
+ val coroutinesDebugJar = sourceSet.runtimeClasspath.filter {it.name == " kotlinx-coroutines-debug-${coroutines_version} .jar" }.singleFile
150
+ jvmArgs (" -javaagent:" + coroutinesDebugJar)
149
151
testClassesDirs = sourceSet.output.classesDirs
150
152
classpath = sourceSet.runtimeClasspath
151
- systemProperties project . properties. subMap([" overwrite.probes" ])
153
+ systemProperties(rootProject .properties.subMap([" overwrite.probes" ]) )
152
154
}
153
155
154
- task debugDynamicAgentTest ( type : Test ) {
155
- def sourceSet = sourceSets. debugDynamicAgentTest
156
+ tasks.create< Test >( " debugDynamicAgentTest " ) {
157
+ val sourceSet = sourceSets.debugDynamicAgentTest
156
158
testClassesDirs = sourceSet.output.classesDirs
157
159
classpath = sourceSet.runtimeClasspath
158
160
}
159
161
160
- task coreAgentTest ( type : Test ) {
161
- def sourceSet = sourceSets. coreAgentTest
162
- def coroutinesCoreJar = sourceSet. runtimeClasspath. filter {it. name == " kotlinx-coroutines-core-jvm-${ coroutines_version} .jar" }. singleFile
163
- jvmArgs (' -javaagent:' + coroutinesCoreJar)
162
+ tasks.create< Test >( " coreAgentTest " ) {
163
+ val sourceSet = sourceSets.coreAgentTest
164
+ val coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == " kotlinx-coroutines-core-jvm-${coroutines_version} .jar" }.singleFile
165
+ jvmArgs (" -javaagent:" + coroutinesCoreJar)
164
166
testClassesDirs = sourceSet.output.classesDirs
165
167
classpath = sourceSet.runtimeClasspath
166
168
}
@@ -170,7 +172,7 @@ compileTestKotlin {
170
172
}
171
173
172
174
check {
173
- dependsOn([jvmCoreTest, debugDynamicAgentTest, mavenTest, debugAgentTest, coreAgentTest, ' smokeTest:build' ])
175
+ dependsOn([jvmCoreTest, debugDynamicAgentTest, mavenTest, debugAgentTest, coreAgentTest, " smokeTest:build" ])
174
176
}
175
177
compileKotlin {
176
178
kotlinOptions {
0 commit comments