1
1
import org.jetbrains.kotlin.config.KotlinCompilerVersion
2
- import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2
+ import org.jetbrains.kotlin.gradle.dsl.*
3
+ import org.gradle.kotlin.dsl.*
3
4
import org.jetbrains.kotlin.konan.target.HostManager
4
5
5
- import static Projects .*
6
-
7
6
buildscript {
8
- ext.kotlin_version = CommunityProjectsBuild .getOverriddenKotlinVersion(rootProject)
9
-
10
- if (CommunityProjectsBuild .shouldUseLocalMaven(rootProject)) {
7
+ if (shouldUseLocalMaven(rootProject)) {
11
8
repositories {
12
9
mavenLocal()
13
10
}
14
11
}
15
12
16
13
repositories {
17
14
mavenCentral()
18
- maven { url " https://plugins.gradle.org/m2/" }
19
- CommunityProjectsBuild . addDevRepositoryIfEnabled(delegate , project)
15
+ maven( url = " https://plugins.gradle.org/m2/" )
16
+ addDevRepositoryIfEnabled(this , project)
20
17
mavenLocal()
21
18
}
22
19
23
20
dependencies {
24
21
// Please ensure that atomicfu-gradle-plugin is added to the classpath first, do not change the order, for details see #3984.
25
22
// The corresponding issue in kotlinx-atomicfu: https://github.com/Kotlin/kotlinx-atomicfu/issues/384
26
- classpath " org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version "
27
- classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
28
- classpath " org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version "
29
- classpath " org.jetbrains.kotlinx:kotlinx-knit:$knit_version "
30
- classpath " org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version "
31
- classpath " ru.vyarus:gradle-animalsniffer-plugin:$animalsniffer_version " // Android API check
32
- classpath " org.jetbrains.kotlin:atomicfu:$kotlin_version "
33
- classpath " org.jetbrains.kotlinx:kover-gradle-plugin:$kover_version "
23
+ classpath( " org.jetbrains.kotlinx:atomicfu-gradle-plugin:${version( " atomicfu " )} " )
24
+ classpath( " org.jetbrains.kotlin:kotlin-gradle-plugin:${version( " kotlin " )} " )
25
+ classpath( " org.jetbrains.dokka:dokka-gradle-plugin:${version( " dokka " )} " )
26
+ classpath( " org.jetbrains.kotlinx:kotlinx-knit:${version( " knit " )} " )
27
+ classpath( " org.jetbrains.kotlinx:binary-compatibility-validator:${version( " binary_compatibility_validator " )} " )
28
+ classpath( " ru.vyarus:gradle-animalsniffer-plugin:${version( " animalsniffer " )} " ) // Android API check
29
+ classpath( " org.jetbrains.kotlin:atomicfu:${version( " kotlin " )} " )
30
+ classpath( " org.jetbrains.kotlinx:kover-gradle-plugin:${version( " kover " )} " )
34
31
35
32
// JMH plugins
36
- classpath " gradle.plugin.com.github.johnrengelman:shadow:$shadow_version "
33
+ classpath( " gradle.plugin.com.github.johnrengelman:shadow:${version( " shadow " )} " )
37
34
}
38
35
39
- CacheRedirector .configureBuildScript(buildscript, rootProject)
40
- }
41
-
42
- // todo:KLUDGE: This is needed to workaround dependency resolution between Java and MPP modules
43
- def configureKotlinJvmPlatform(configuration) {
44
- configuration.attributes.attribute(KotlinPlatformType .attribute, KotlinPlatformType .jvm)
36
+ with (CacheRedirector ) { buildscript.configureBuildScript(rootProject) }
45
37
}
46
38
47
39
// Configure subprojects with Kotlin sources
48
- apply plugin: " configure-compilation-conventions"
40
+ apply ( plugin = " configure-compilation-conventions" )
49
41
50
42
allprojects {
51
43
// the only place where HostManager could be instantiated
52
- project.ext. hostManager = new HostManager ()
53
- def deployVersion = properties[' DeployVersion' ]
44
+ project.ext[ " hostManager" ] = HostManager ()
45
+ val deployVersion = properties[" DeployVersion" ]
54
46
if (deployVersion != null ) version = deployVersion
55
47
56
- if (CommunityProjectsBuild . isSnapshotTrainEnabled(rootProject)) {
57
- def skipSnapshotChecks = rootProject.properties[' skip_snapshot_checks' ] != null
58
- if (! skipSnapshotChecks && version != atomicfu_version ) {
59
- throw new IllegalStateException (" Current deploy version is $version , but atomicfu version is not overridden ($atomicfu_version ) for $it " )
48
+ if (isSnapshotTrainEnabled(rootProject)) {
49
+ val skipSnapshotChecks = rootProject.properties[" skip_snapshot_checks" ] != null
50
+ if (! skipSnapshotChecks && version != version( " atomicfu " ) ) {
51
+ throw IllegalStateException (" Current deploy version is $version , but atomicfu version is not overridden (${version( " atomicfu " )} ) for $this " )
60
52
}
61
53
}
62
54
63
- if (CommunityProjectsBuild . shouldUseLocalMaven(rootProject)) {
55
+ if (shouldUseLocalMaven(rootProject)) {
64
56
repositories {
65
57
mavenLocal()
66
58
}
67
59
}
68
60
69
61
// This project property is set during nightly stress test
70
- def stressTest = project.properties[' stressTest' ]
71
-
62
+ val stressTest = project.properties[" stressTest" ]
72
63
// Copy it to all test tasks
73
- tasks.withType(Test ).configureEach {
74
- systemProperty ' stressTest' , stressTest
64
+ tasks.withType(Test ::class ).configureEach {
65
+ if (stressTest != null ) {
66
+ systemProperty(" stressTest" , stressTest)
67
+ }
75
68
}
76
69
}
77
70
78
- apply plugin: " binary-compatibility-validator"
79
- apply plugin: " base"
80
- apply plugin: " kover-conventions"
71
+ plugins {
72
+ id(" org.jetbrains.kotlinx.binary-compatibility-validator" ) version " 0.13.2"
73
+ }
74
+
75
+ apply (plugin = " base" )
76
+ apply (plugin = " kover-conventions" )
81
77
82
78
apiValidation {
83
- ignoredProjects + = unpublished + [ " kotlinx-coroutines-bom" ]
84
- if (CommunityProjectsBuild . isSnapshotTrainEnabled(rootProject)) {
85
- ignoredProjects.add( coreModule)
79
+ ignoredProjects + = unpublished + listOf ( " kotlinx-coroutines-bom" )
80
+ if (isSnapshotTrainEnabled(rootProject)) {
81
+ ignoredProjects + = coreModule
86
82
}
87
83
ignoredPackages + = " kotlinx.coroutines.internal"
88
84
}
@@ -96,69 +92,79 @@ allprojects {
96
92
*/
97
93
google()
98
94
mavenCentral()
99
- CommunityProjectsBuild . addDevRepositoryIfEnabled(delegate , project)
95
+ addDevRepositoryIfEnabled(this , project)
100
96
}
101
97
}
102
98
103
99
// needs to be before evaluationDependsOn due to weird Gradle ordering
104
- apply plugin: " animalsniffer-conventions"
105
-
106
- configure(subprojects.findAll { ! sourceless.contains(it.name) }) {
107
- if (isMultiplatform(it) ) {
108
- apply plugin: ' kotlin-multiplatform'
109
- apply plugin: " kotlin-multiplatform-conventions"
110
- } else if (PlatformKt . platformOf(it ) == " jvm" ) {
111
- apply plugin: " kotlin-jvm-conventions"
100
+ apply ( plugin = " animalsniffer-conventions" )
101
+
102
+ configure(subprojects.filter { ! sourceless.contains(it.name) }) {
103
+ if (isMultiplatform) {
104
+ apply ( plugin = " kotlin-multiplatform" )
105
+ apply ( plugin = " kotlin-multiplatform-conventions" )
106
+ } else if (platformOf(this ) == " jvm" ) {
107
+ apply ( plugin = " kotlin-jvm-conventions" )
112
108
} else {
113
- def platform = PlatformKt . platformOf(it )
109
+ val platform = platformOf(this )
114
110
throw IllegalStateException (" No configuration rules for $platform " )
115
111
}
116
112
}
117
113
118
114
// Add dependency to the core module in all the other subprojects.
119
- configure(subprojects.findAll { ! sourceless.contains(it.name) && it.name != coreModule }) {
115
+ configure(subprojects.filter { ! sourceless.contains(it.name) && it.name != coreModule }) {
120
116
evaluationDependsOn(" :$coreModule " )
121
- if (isMultiplatform(it)) {
122
- kotlin.sourceSets.commonMain.dependencies {
123
- api project(" :$coreModule " )
124
- }
125
- kotlin.sourceSets.jvmTest.dependencies {
126
- implementation project(" :$coreModule " ).kotlin.targets.jvm.compilations.test.output.allOutputs
117
+ val jvmTestDependency = project(" :$coreModule " )
118
+ .extensions.getByType(KotlinMultiplatformExtension ::class )
119
+ .targets[" jvm" ].compilations[" test" ].output.allOutputs
120
+ if (isMultiplatform) {
121
+ configure<KotlinMultiplatformExtension > {
122
+ sourceSets {
123
+ commonMain {
124
+ dependencies {
125
+ api(project(" :$coreModule " ))
126
+ }
127
+ }
128
+ jvmTest {
129
+ dependencies {
130
+ implementation(jvmTestDependency)
131
+ }
132
+ }
133
+ }
127
134
}
128
135
} else {
129
136
dependencies {
130
- api project(" :$coreModule " )
137
+ add( " api" , project(" :$coreModule " ) )
131
138
// the only way IDEA can resolve test classes
132
- testImplementation project( " : $coreModule " ).kotlin.targets.jvm.compilations.test.output.allOutputs
139
+ add( " testImplementation " , jvmTestDependency)
133
140
}
134
141
}
135
142
}
136
143
137
- apply plugin: " bom-conventions"
138
- apply plugin: " java-modularity-conventions"
139
- apply plugin: " version-file-conventions"
144
+ apply ( plugin = " bom-conventions" )
145
+ apply ( plugin = " java-modularity-conventions" )
146
+ apply ( plugin = " version-file-conventions" )
140
147
141
- CommunityProjectsBuild .configureCommunityBuildTweaks(rootProject )
148
+ rootProject .configureCommunityBuildTweaks()
142
149
143
- apply plugin: " source-set-conventions"
144
- apply plugin: " dokka-conventions"
145
- apply plugin: " knit-conventions"
150
+ apply ( plugin = " source-set-conventions" )
151
+ apply ( plugin = " dokka-conventions" )
152
+ apply ( plugin = " knit-conventions" )
146
153
147
154
/*
148
155
* TODO: core and non-core cannot be configured via 'configure(subprojects)'
149
156
* because of 'afterEvaluate' issue. This one should be migrated to
150
157
* `plugins { id("pub-conventions") }` eventually
151
158
*/
152
- configure(subprojects.findAll {
159
+ configure(subprojects.filter {
153
160
! unpublished.contains(it.name) && it.name != coreModule
154
161
}) {
155
- apply plugin: " pub-conventions"
162
+ apply ( plugin = " pub-conventions" )
156
163
}
157
164
158
165
AuxBuildConfiguration .configure(rootProject)
159
- PublishingKt .registerTopLevelDeployTask(rootProject )
166
+ rootProject .registerTopLevelDeployTask()
160
167
161
168
// Report Kotlin compiler version when building project
162
- println (" Using Kotlin compiler version: $KotlinCompilerVersion .VERSION" )
163
-
169
+ println (" Using Kotlin compiler version: ${KotlinCompilerVersion .VERSION } " )
164
170
0 commit comments