Skip to content

Commit fdf5813

Browse files
authored
Gradle cleanup (#121)
* Extract all versions to gradle.properties * Remove workaround for publishing * Remove not needed logic in root build.gradle.kts
1 parent 8784c39 commit fdf5813

File tree

6 files changed

+84
-68
lines changed

6 files changed

+84
-68
lines changed

benchmarks/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.*
1818

1919
plugins {
2020
kotlin("multiplatform")
21-
id("kotlinx.benchmark") version "0.2.0-dev-20"
22-
kotlin("plugin.allopen") version "1.4.10"
21+
id("kotlinx.benchmark")
22+
kotlin("plugin.allopen")
2323
}
2424

2525
repositories {
@@ -28,6 +28,7 @@ repositories {
2828

2929
val rsocketJavaVersion: String by rootProject
3030
val kotlinxCoroutinesVersion: String by rootProject
31+
val kotlinxBenchmarkVersion: String by rootProject
3132

3233
kotlin {
3334
val jvm = jvm() //common jvm source set
@@ -37,7 +38,7 @@ kotlin {
3738
sourceSets {
3839
val commonMain by getting {
3940
dependencies {
40-
implementation("org.jetbrains.kotlinx:kotlinx.benchmark.runtime:0.2.0-dev-20")
41+
implementation("org.jetbrains.kotlinx:kotlinx.benchmark.runtime:$kotlinxBenchmarkVersion")
4142
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
4243
}
4344
}

build.gradle.kts

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ allprojects {
5353
}
5454
}
5555

56-
//true when on CI, and false when local dev. Needed for native build configuration
56+
//true when on CI, and false when local dev. Needed for build configuration
5757
val ciRun = System.getenv("CI") == "true"
5858

5959
//configure main host, for which jvm and js tests are enabled, true if locally, or linux on CI
@@ -62,7 +62,7 @@ val isMainHost: Boolean = !ciRun || HostManager.hostIsLinux
6262
// can be: macos, ios, watchos, tvos. If provided, compile and test only those targets
6363
val macTargetsCompilation: String? by project
6464

65-
println("Configuration: CI=${System.getenv("CI")}, ciRun=$ciRun, isMainHost=$isMainHost, macTargetsCompilation=$macTargetsCompilation")
65+
println("Configuration: ciRun=$ciRun, isMainHost=$isMainHost, macTargetsCompilation=$macTargetsCompilation")
6666

6767
val Project.publicationNames: Array<String>
6868
get() {
@@ -125,55 +125,55 @@ subprojects {
125125
}
126126

127127
//native targets configuration
128-
if (ciRun) {
129-
fun KotlinNativeTarget.disableCompilation() {
130-
compilations.all { compileKotlinTask.enabled = false }
131-
binaries.all { linkTask.enabled = false }
132-
}
128+
val hostTargets = listOfNotNull(linuxX64(), macosX64(), if (supportMingw) mingwX64() else null)
133129

134-
val hostTargets = listOfNotNull(linuxX64(), macosX64(), if (supportMingw) mingwX64() else null)
130+
val iosTargets = listOf(iosArm32(), iosArm64(), iosX64())
131+
val tvosTargets = listOf(tvosArm64(), tvosX64())
132+
val watchosTargets = listOf(watchosArm32(), watchosArm64(), watchosX86())
133+
val nativeTargets = hostTargets + iosTargets + tvosTargets + watchosTargets
135134

136-
val iosTargets = listOf(iosArm32(), iosArm64(), iosX64())
137-
val tvosTargets = listOf(tvosArm64(), tvosX64())
138-
val watchosTargets = listOf(watchosArm32(), watchosArm64(), watchosX86())
139-
val nativeTargets = hostTargets + iosTargets + tvosTargets + watchosTargets
135+
val nativeMain by sourceSets.creating {
136+
dependsOn(sourceSets["commonMain"])
137+
}
138+
val nativeTest by sourceSets.creating {
139+
dependsOn(sourceSets["commonTest"])
140+
}
140141

141-
val nativeMain by sourceSets.creating {
142-
dependsOn(sourceSets["commonMain"])
143-
}
144-
val nativeTest by sourceSets.creating {
145-
dependsOn(sourceSets["commonTest"])
146-
}
142+
nativeTargets.forEach {
143+
sourceSets["${it.name}Main"].dependsOn(nativeMain)
144+
sourceSets["${it.name}Test"].dependsOn(nativeTest)
145+
}
147146

148-
nativeTargets.forEach {
149-
sourceSets["${it.name}Main"].dependsOn(nativeMain)
150-
sourceSets["${it.name}Test"].dependsOn(nativeTest)
151-
}
147+
fun KotlinNativeTarget.disableCompilation() {
148+
compilations.all { compileKotlinTask.enabled = false }
149+
binaries.all { linkTask.enabled = false }
150+
}
152151

153-
//disable cross compilation of linux target on non linux hosts
154-
if (!HostManager.hostIsLinux) linuxX64().disableCompilation()
155-
156-
//disable compilation of part of mac targets
157-
if (HostManager.hostIsMac) when (macTargetsCompilation) {
158-
"macos" -> iosTargets + tvosTargets + watchosTargets
159-
"ios", "watchos", "tvos" -> {
160-
//disable test compilation for macos, but leave main to compile examples and playground
161-
macosX64 {
162-
compilations.all { if (name == "test") compileKotlinTask.enabled = false }
163-
binaries.all { linkTask.enabled = false }
164-
}
165-
when (macTargetsCompilation) {
166-
"ios" -> tvosTargets + watchosTargets
167-
"watchos" -> iosTargets + tvosTargets
168-
"tvos" -> iosTargets + watchosTargets
169-
else -> emptyList()
170-
}
152+
//disable cross compilation of linux target on non linux hosts
153+
if (!HostManager.hostIsLinux) linuxX64().disableCompilation()
154+
155+
//disable compilation of part of mac targets
156+
if (HostManager.hostIsMac) when (macTargetsCompilation) {
157+
"macos" -> iosTargets + tvosTargets + watchosTargets
158+
"ios", "watchos", "tvos" -> {
159+
//disable test compilation for macos, but leave main to compile examples and playground
160+
macosX64 {
161+
compilations.all { if (name == "test") compileKotlinTask.enabled = false }
162+
binaries.all { linkTask.enabled = false }
163+
}
164+
when (macTargetsCompilation) {
165+
"ios" -> tvosTargets + watchosTargets
166+
"watchos" -> iosTargets + tvosTargets
167+
"tvos" -> iosTargets + watchosTargets
168+
else -> emptyList()
171169
}
172-
else -> emptyList()
173-
}.forEach(KotlinNativeTarget::disableCompilation)
170+
}
171+
else -> emptyList()
172+
}.forEach(KotlinNativeTarget::disableCompilation)
174173

175-
//run tests on release + mimalloc to reduce tests execution time
176-
//compilation is slower in that mode, but work with buffers is much faster
174+
//run tests on release + mimalloc to reduce tests execution time
175+
//compilation is slower in that mode, but work with buffers is much faster
176+
if (ciRun) {
177177
targets.all {
178178
if (this is KotlinNativeTargetWithTests<*>) {
179179
binaries.test(listOf(RELEASE))
@@ -183,13 +183,6 @@ subprojects {
183183
}
184184
}
185185
}
186-
} else {
187-
//if not on CI, use only one native target same as host, DON'T PUBLISH IN THAT MODE LOCALLY!!!
188-
when {
189-
HostManager.hostIsLinux -> linuxX64("native")
190-
HostManager.hostIsMingw && supportMingw -> mingwX64("native")
191-
HostManager.hostIsMac -> macosX64("native")
192-
}
193186
}
194187
}
195188

examples/multiplatform-chat/build.gradle.kts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ import org.jetbrains.kotlin.konan.target.*
1818

1919
plugins {
2020
kotlin("multiplatform")
21-
kotlin("plugin.serialization") version "1.4.10"
21+
kotlin("plugin.serialization")
2222
id("kotlinx-atomicfu")
2323
}
2424

25+
val ktorVersion: String by rootProject
26+
val kotlinxSerializationVersion: String by rootProject
27+
2528
kotlin {
2629
jvm("serverJvm")
2730
jvm("clientJvm")
@@ -49,7 +52,7 @@ kotlin {
4952
dependencies {
5053
implementation(project(":rsocket-core"))
5154

52-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.0.0-RC")
55+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlinxSerializationVersion")
5356
}
5457
}
5558

@@ -63,21 +66,21 @@ kotlin {
6366
val serverJvmMain by getting {
6467
dependencies {
6568
implementation(project(":rsocket-transport-ktor-server"))
66-
implementation("io.ktor:ktor-server-cio:1.4.1")
69+
implementation("io.ktor:ktor-server-cio:$ktorVersion")
6770
}
6871
}
6972

7073
val clientJvmMain by getting {
7174
dependsOn(clientMain)
7275
dependencies {
73-
implementation("io.ktor:ktor-client-cio:1.4.1")
76+
implementation("io.ktor:ktor-client-cio:$ktorVersion")
7477
}
7578
}
7679

7780
val clientJsMain by getting {
7881
dependsOn(clientMain)
7982
dependencies {
80-
implementation("io.ktor:ktor-client-js:1.4.1")
83+
implementation("io.ktor:ktor-client-js:$ktorVersion")
8184
}
8285
}
8386

examples/nodejs-tcp-transport/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ plugins {
1818
kotlin("multiplatform")
1919
}
2020

21+
val kotlinxNodejsVersion: String by rootProject
22+
2123
kotlin {
2224
js(IR) {
2325
nodejs {
@@ -29,7 +31,7 @@ kotlin {
2931
val jsMain by getting {
3032
dependencies {
3133
implementation(project(":rsocket-core"))
32-
implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7")
34+
implementation("org.jetbrains.kotlinx:kotlinx-nodejs:$kotlinxNodejsVersion")
3335
}
3436
}
3537
}

gradle.properties

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ kotlinVersion=1.4.10
2323
ktorVersion=1.4.1
2424
kotlinxCoroutinesVersion=1.3.9-native-mt-2
2525
kotlinxAtomicfuVersion=0.14.4
26+
kotlinxSerializationVersion=1.0.0-RC
27+
kotlinxBenchmarkVersion=0.2.0-dev-20
28+
kotlinxNodejsVersion=0.0.7
29+
rsocketJavaVersion=1.1.0
2630
turbineVersion=0.2.1
27-
rsocketJavaVersion=1.1.0-M2
31+
bintrayVersion=1.8.5
32+
artifactoryVersion=4.17.2
33+
versionUpdatesVersion=0.33.0
34+
gradleEnterpriseVersion=3.4.1
2835

2936
#Kotlin
3037
#kotlin.code.style=official
@@ -52,6 +59,3 @@ org.gradle.caching=true
5259
org.gradle.configureondemand=true
5360
org.gradle.jvmargs=-Xmx4g
5461
org.gradle.vfs.watch=true
55-
56-
#Bintray publish workaround
57-
systemProp.org.gradle.internal.publish.checksums.insecure=true

settings.gradle.kts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,28 @@ pluginManagement {
2121
maven("https://dl.bintray.com/kotlin/kotlinx")
2222
}
2323

24+
val kotlinVersion: String by settings
25+
val bintrayVersion: String by settings
26+
val artifactoryVersion: String by settings
27+
val versionUpdatesVersion: String by settings
28+
val gradleEnterpriseVersion: String by settings
29+
val kotlinxBenchmarkVersion: String by settings
30+
2431
plugins {
25-
id("com.jfrog.bintray") version "1.8.5"
26-
id("com.jfrog.artifactory") version "4.17.2"
27-
id("com.github.ben-manes.versions") version "0.33.0"
32+
kotlin("plugin.allopen") version kotlinVersion
33+
kotlin("plugin.serialization") version kotlinVersion
34+
35+
id("kotlinx.benchmark") version kotlinxBenchmarkVersion
36+
37+
id("com.jfrog.bintray") version bintrayVersion
38+
id("com.jfrog.artifactory") version artifactoryVersion
39+
id("com.github.ben-manes.versions") version versionUpdatesVersion
40+
id("com.gradle.enterprise") version gradleEnterpriseVersion
2841
}
2942
}
3043

3144
plugins {
32-
id("com.gradle.enterprise") version "3.4.1"
45+
id("com.gradle.enterprise")
3346
}
3447

3548
gradleEnterprise {

0 commit comments

Comments
 (0)