Skip to content

Commit cd050d5

Browse files
committed
build logic cleanup step 2
* drop target-specific convention plugins, as KGP now generates accessors * use targets helpers in projects * drop template convention plugins, leave only library - inline usages * create test aggregate tasks * reduce usages of OptIns * use jvm-default=all (easier compatibility in future) * drop test server completely for now from `rsocket-transport-tests`
1 parent b822227 commit cd050d5

File tree

35 files changed

+492
-733
lines changed

35 files changed

+492
-733
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Copyright 2015-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import org.jetbrains.kotlin.gradle.*
18+
import org.jetbrains.kotlin.gradle.plugin.*
19+
import org.jetbrains.kotlin.gradle.plugin.mpp.*
20+
import org.jetbrains.kotlin.gradle.targets.js.ir.*
21+
import org.jetbrains.kotlin.gradle.targets.jvm.*
22+
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.*
23+
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
24+
import org.jetbrains.kotlin.gradle.tasks.*
25+
import rsocketbuild.*
26+
import rsocketbuild.tests.*
27+
28+
plugins {
29+
kotlin("multiplatform")
30+
}
31+
32+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
33+
kotlin {
34+
compilerOptions {
35+
// allWarningsAsErrors.set(true)
36+
progressiveMode.set(true)
37+
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
38+
}
39+
40+
sourceSets.configureEach {
41+
languageSettings {
42+
if (name.contains("test", ignoreCase = true)) {
43+
optIn(OptIns.ExperimentalStdlibApi)
44+
optIn(OptIns.DelicateCoroutinesApi)
45+
46+
// rsocket related
47+
optIn(OptIns.TransportApi)
48+
optIn(OptIns.ExperimentalMetadataApi)
49+
optIn(OptIns.ExperimentalStreamsApi)
50+
optIn(OptIns.RSocketLoggingApi)
51+
}
52+
}
53+
}
54+
55+
targets.withType<KotlinJvmTarget>().configureEach {
56+
compilations.configureEach {
57+
compilerOptions.configure {
58+
freeCompilerArgs.add("-Xjvm-default=all")
59+
}
60+
}
61+
}
62+
63+
// revisit JS block after WASM support
64+
targets.withType<KotlinJsIrTarget>().configureEach {
65+
whenBrowserConfigured {
66+
testTask {
67+
useKarma {
68+
useConfigDirectory(rootDir.resolve("gradle/js/karma.config.d"))
69+
useChromeHeadless()
70+
}
71+
}
72+
}
73+
whenNodejsConfigured {
74+
testTask {
75+
useMocha {
76+
timeout = "600s"
77+
}
78+
}
79+
}
80+
}
81+
82+
//setup tests running in RELEASE mode
83+
targets.withType<KotlinNativeTarget>().configureEach {
84+
binaries.test(listOf(NativeBuildType.RELEASE))
85+
}
86+
targets.withType<KotlinNativeTargetWithTests<*>>().configureEach {
87+
testRuns.create("releaseTest") {
88+
setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE))
89+
}
90+
}
91+
}
92+
93+
// for CI mainly
94+
95+
registerTestAggregationTask(
96+
name = "jvmAllTest",
97+
taskDependencies = { tasks.withType<KotlinJvmTest>() },
98+
targetFilter = { it.platformType == KotlinPlatformType.jvm }
99+
)
100+
101+
registerTestAggregationTask(
102+
name = "nativeTest",
103+
taskDependencies = { tasks.withType<KotlinNativeTest>().matching { it.enabled } },
104+
targetFilter = { it.platformType == KotlinPlatformType.native }
105+
)
106+
107+
listOf("ios", "watchos", "tvos", "macos").forEach { targetGroup ->
108+
registerTestAggregationTask(
109+
name = "${targetGroup}Test",
110+
taskDependencies = {
111+
tasks.withType<KotlinNativeTest>().matching {
112+
it.enabled && it.name.startsWith(targetGroup, ignoreCase = true)
113+
}
114+
},
115+
targetFilter = {
116+
it.platformType == KotlinPlatformType.native && it.name.startsWith(targetGroup, ignoreCase = true)
117+
}
118+
)
119+
}
120+
121+
// on build, link even those binaries, which it's not possible to run
122+
tasks.build {
123+
dependsOn(tasks.withType<KotlinNativeLink>())
124+
}
125+
126+
if (providers.gradleProperty("rsocketbuild.skipTests").map(String::toBoolean).getOrElse(false)) {
127+
tasks.withType<AbstractTestTask>().configureEach { onlyIf { false } }
128+
}
129+
130+
if (providers.gradleProperty("rsocketbuild.skipNativeLink").map(String::toBoolean).getOrElse(false)) {
131+
tasks.withType<KotlinNativeLink>().configureEach { onlyIf { false } }
132+
}

build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts renamed to build-logic/src/main/kotlin/rsocketbuild.multiplatform-library.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
*/
1616

1717
plugins {
18-
id("rsocketbuild.target.native.nix")
18+
id("rsocketbuild.multiplatform-base")
19+
id("rsocketbuild.publication")
1920
}
2021

2122
kotlin {
22-
mingwX64()
23+
explicitApi()
2324
}

build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts

Lines changed: 0 additions & 49 deletions
This file was deleted.

build-logic/src/main/kotlin/rsocketbuild.multiplatform.native.gradle.kts

Lines changed: 0 additions & 33 deletions
This file was deleted.

build-logic/src/main/kotlin/rsocketbuild.target.all.gradle.kts

Lines changed: 0 additions & 21 deletions
This file was deleted.

build-logic/src/main/kotlin/rsocketbuild.target.js.all.gradle.kts

Lines changed: 0 additions & 20 deletions
This file was deleted.

build-logic/src/main/kotlin/rsocketbuild.target.js.browser.gradle.kts

Lines changed: 0 additions & 32 deletions
This file was deleted.

build-logic/src/main/kotlin/rsocketbuild.target.js.node.gradle.kts

Lines changed: 0 additions & 31 deletions
This file was deleted.

build-logic/src/main/kotlin/rsocketbuild.target.jvm.gradle.kts

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)