11import 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.*
34import org.jetbrains.kotlin.konan.target.HostManager
45
5- import static Projects .*
6-
76buildscript {
8- ext.kotlin_version = CommunityProjectsBuild .getOverriddenKotlinVersion(rootProject)
9-
10- if (CommunityProjectsBuild .shouldUseLocalMaven(rootProject)) {
7+ if (shouldUseLocalMaven(rootProject)) {
118 repositories {
129 mavenLocal()
1310 }
1411 }
1512
1613 repositories {
1714 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)
2017 mavenLocal()
2118 }
2219
2320 dependencies {
2421 // Please ensure that atomicfu-gradle-plugin is added to the classpath first, do not change the order, for details see #3984.
2522 // 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 " )} " )
3431
3532 // JMH plugins
36- classpath " gradle.plugin.com.github.johnrengelman:shadow:$shadow_version "
33+ classpath( " gradle.plugin.com.github.johnrengelman:shadow:${version( " shadow " )} " )
3734 }
3835
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) }
4537}
4638
4739// Configure subprojects with Kotlin sources
48- apply plugin: " configure-compilation-conventions"
40+ apply ( plugin = " configure-compilation-conventions" )
4941
5042allprojects {
5143 // 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" ]
5446 if (deployVersion != null ) version = deployVersion
5547
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 " )
6052 }
6153 }
6254
63- if (CommunityProjectsBuild . shouldUseLocalMaven(rootProject)) {
55+ if (shouldUseLocalMaven(rootProject)) {
6456 repositories {
6557 mavenLocal()
6658 }
6759 }
6860
6961 // This project property is set during nightly stress test
70- def stressTest = project.properties[' stressTest' ]
71-
62+ val stressTest = project.properties[" stressTest" ]
7263 // 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+ }
7568 }
7669}
7770
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" )
8177
8278apiValidation {
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
8682 }
8783 ignoredPackages + = " kotlinx.coroutines.internal"
8884}
@@ -96,69 +92,79 @@ allprojects {
9692 */
9793 google()
9894 mavenCentral()
99- CommunityProjectsBuild . addDevRepositoryIfEnabled(delegate , project)
95+ addDevRepositoryIfEnabled(this , project)
10096 }
10197}
10298
10399// 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" )
112108 } else {
113- def platform = PlatformKt . platformOf(it )
109+ val platform = platformOf(this )
114110 throw IllegalStateException (" No configuration rules for $platform " )
115111 }
116112}
117113
118114// 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 }) {
120116 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+ }
127134 }
128135 } else {
129136 dependencies {
130- api project(" :$coreModule " )
137+ add( " api" , project(" :$coreModule " ) )
131138 // the only way IDEA can resolve test classes
132- testImplementation project( " : $coreModule " ).kotlin.targets.jvm.compilations.test.output.allOutputs
139+ add( " testImplementation " , jvmTestDependency)
133140 }
134141 }
135142}
136143
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" )
140147
141- CommunityProjectsBuild .configureCommunityBuildTweaks(rootProject )
148+ rootProject .configureCommunityBuildTweaks()
142149
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" )
146153
147154/*
148155 * TODO: core and non-core cannot be configured via 'configure(subprojects)'
149156 * because of 'afterEvaluate' issue. This one should be migrated to
150157 * `plugins { id("pub-conventions") }` eventually
151158 */
152- configure(subprojects.findAll {
159+ configure(subprojects.filter {
153160 ! unpublished.contains(it.name) && it.name != coreModule
154161}) {
155- apply plugin: " pub-conventions"
162+ apply ( plugin = " pub-conventions" )
156163}
157164
158165AuxBuildConfiguration .configure(rootProject)
159- PublishingKt .registerTopLevelDeployTask(rootProject )
166+ rootProject .registerTopLevelDeployTask()
160167
161168// Report Kotlin compiler version when building project
162- println (" Using Kotlin compiler version: $KotlinCompilerVersion .VERSION" )
163-
169+ println (" Using Kotlin compiler version: ${KotlinCompilerVersion .VERSION } " )
164170
0 commit comments