Skip to content

Commit ec8442c

Browse files
committed
Build logic cleanup
* align build-logic plugins with Gradle suggestions; * introduce build-logic-settings for multiple settings configuration; * move kotlin version to Version Catalog; * move build-logic to root of the project; * remove build-parameters; * rename build-logic plugins; * minor cleanup in the publication script; * drop target-specific convention plugins, as KGP now generates; accessors; * use targets helpers in projects; * drop template convention plugins; * 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`; * Update some Gradle properties; * implement small DSL for including projects;
1 parent 77a8279 commit ec8442c

File tree

53 files changed

+832
-1054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+832
-1054
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ jobs:
120120
--scan
121121
--info
122122
--continue
123-
-Pskip.test
123+
-Prsocketbuild.skipTests=true

gradle/plugins/kotlin-version-catalog/build.gradle.kts renamed to build-logic/build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 the original author or authors.
2+
* Copyright 2015-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,10 +18,6 @@ plugins {
1818
`kotlin-dsl`
1919
}
2020

21-
kotlin {
22-
jvmToolchain(8)
23-
}
24-
2521
dependencies {
26-
implementation("rsocket.build:build-parameters")
22+
implementation(libs.kotlin.gradle.plugin)
2723
}
Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 the original author or authors.
2+
* Copyright 2015-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,30 +15,19 @@
1515
*/
1616

1717
pluginManagement {
18-
repositories {
19-
gradlePluginPortal()
20-
mavenCentral()
21-
}
22-
includeBuild("../kotlin-version-catalog")
18+
includeBuild("../build-settings")
2319
}
2420

25-
dependencyResolutionManagement {
26-
repositories {
27-
gradlePluginPortal()
28-
mavenCentral()
29-
}
21+
plugins {
22+
id("rsocketsettings.default")
23+
}
3024

25+
dependencyResolutionManagement {
3126
versionCatalogs {
3227
create("libs") {
33-
from(files("../../libs.versions.toml"))
28+
from(files("../gradle/libs.versions.toml"))
3429
}
3530
}
3631
}
3732

38-
plugins {
39-
id("kotlin-version-catalog")
40-
}
41-
4233
rootProject.name = "build-logic"
43-
44-
includeBuild("../build-parameters")
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
// because of https://youtrack.jetbrains.com/issue/KT-64115/KGP-JVM-JS-WASM-The-same-library-can-be-passed-twice-to-the-compiler
36+
// allWarningsAsErrors.set(true)
37+
progressiveMode.set(true)
38+
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
39+
}
40+
41+
sourceSets.configureEach {
42+
languageSettings {
43+
if (name.contains("test", ignoreCase = true)) {
44+
optIn(OptIns.ExperimentalStdlibApi)
45+
optIn(OptIns.DelicateCoroutinesApi)
46+
47+
// rsocket related
48+
optIn(OptIns.TransportApi)
49+
optIn(OptIns.ExperimentalMetadataApi)
50+
optIn(OptIns.ExperimentalStreamsApi)
51+
optIn(OptIns.RSocketLoggingApi)
52+
}
53+
}
54+
}
55+
56+
targets.withType<KotlinJvmTarget>().configureEach {
57+
compilations.configureEach {
58+
compilerOptions.configure {
59+
freeCompilerArgs.add("-Xjvm-default=all")
60+
}
61+
}
62+
}
63+
64+
// revisit JS block after WASM support
65+
targets.withType<KotlinJsIrTarget>().configureEach {
66+
whenBrowserConfigured {
67+
testTask {
68+
useKarma {
69+
useConfigDirectory(rootDir.resolve("gradle/js/karma.config.d"))
70+
useChromeHeadless()
71+
}
72+
}
73+
}
74+
whenNodejsConfigured {
75+
testTask {
76+
useMocha {
77+
timeout = "600s"
78+
}
79+
}
80+
}
81+
}
82+
83+
//setup tests running in RELEASE mode
84+
targets.withType<KotlinNativeTarget>().configureEach {
85+
binaries.test(listOf(NativeBuildType.RELEASE))
86+
}
87+
targets.withType<KotlinNativeTargetWithTests<*>>().configureEach {
88+
testRuns.create("releaseTest") {
89+
setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE))
90+
}
91+
}
92+
}
93+
94+
// for CI mainly
95+
96+
registerTestAggregationTask(
97+
name = "jvmAllTest",
98+
taskDependencies = { tasks.withType<KotlinJvmTest>() },
99+
targetFilter = { it.platformType == KotlinPlatformType.jvm }
100+
)
101+
102+
registerTestAggregationTask(
103+
name = "nativeTest",
104+
taskDependencies = { tasks.withType<KotlinNativeTest>().matching { it.enabled } },
105+
targetFilter = { it.platformType == KotlinPlatformType.native }
106+
)
107+
108+
listOf("ios", "watchos", "tvos", "macos").forEach { targetGroup ->
109+
registerTestAggregationTask(
110+
name = "${targetGroup}Test",
111+
taskDependencies = {
112+
tasks.withType<KotlinNativeTest>().matching {
113+
it.enabled && it.name.startsWith(targetGroup, ignoreCase = true)
114+
}
115+
},
116+
targetFilter = {
117+
it.platformType == KotlinPlatformType.native && it.name.startsWith(targetGroup, ignoreCase = true)
118+
}
119+
)
120+
}
121+
122+
// on build, link even those binaries, which it's not possible to run
123+
tasks.build {
124+
dependsOn(tasks.withType<KotlinNativeLink>())
125+
}
126+
127+
if (providers.gradleProperty("rsocketbuild.skipTests").map(String::toBoolean).getOrElse(false)) {
128+
tasks.withType<AbstractTestTask>().configureEach { onlyIf { false } }
129+
}
130+
131+
if (providers.gradleProperty("rsocketbuild.skipNativeLink").map(String::toBoolean).getOrElse(false)) {
132+
tasks.withType<KotlinNativeLink>().configureEach { onlyIf { false } }
133+
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 the original author or authors.
2+
* Copyright 2015-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
1515
*/
1616

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

2122
kotlin {
22-
linuxX64()
23+
explicitApi()
2324
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
plugins {
18+
`maven-publish`
19+
signing
20+
}
21+
22+
val githubUsername: String? by project
23+
val githubPassword: String? by project
24+
25+
val sonatypeUsername: String? by project
26+
val sonatypePassword: String? by project
27+
28+
val signingKey: String? by project
29+
val signingPassword: String? by project
30+
31+
// TODO: refactor publication a bit, so that version in gradle.properties will not contain SNAPSHOT
32+
val versionSuffix = providers.gradleProperty("rsocketbuild.versionSuffix").orNull
33+
if (versionSuffix != null) {
34+
val versionString = project.version.toString()
35+
require(versionString.endsWith("-SNAPSHOT"))
36+
project.version = versionString.replace("-", "-${versionSuffix}-")
37+
println("Current version: ${project.version}")
38+
}
39+
40+
// empty javadoc for maven central
41+
val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") }
42+
43+
// this is somewhat a hack because we have a single javadoc artifact which is used for all publications
44+
tasks.withType<Sign>().configureEach { mustRunAfter(javadocJar) }
45+
tasks.withType<AbstractPublishToMaven>().configureEach { mustRunAfter(tasks.withType<Sign>()) }
46+
47+
publishing {
48+
publications.withType<MavenPublication> {
49+
artifact(javadocJar)
50+
pom {
51+
name.set(project.name)
52+
description.set(provider {
53+
checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" }
54+
})
55+
url.set("http://rsocket.io")
56+
57+
licenses {
58+
license {
59+
name.set("The Apache Software License, Version 2.0")
60+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
61+
distribution.set("repo")
62+
}
63+
}
64+
developers {
65+
developer {
66+
id.set("whyoleg")
67+
name.set("Oleg Yukhnevich")
68+
email.set("[email protected]")
69+
}
70+
developer {
71+
id.set("OlegDokuka")
72+
name.set("Oleh Dokuka")
73+
email.set("[email protected]")
74+
}
75+
}
76+
scm {
77+
connection.set("https://github.com/rsocket/rsocket-kotlin.git")
78+
developerConnection.set("https://github.com/rsocket/rsocket-kotlin.git")
79+
url.set("https://github.com/rsocket/rsocket-kotlin")
80+
}
81+
}
82+
}
83+
84+
repositories {
85+
// TODO: drop github and use sonatype (?)
86+
maven {
87+
name = "github"
88+
url = uri("https://maven.pkg.github.com/rsocket/rsocket-kotlin")
89+
credentials {
90+
username = githubUsername
91+
password = githubPassword
92+
}
93+
}
94+
maven {
95+
name = "sonatype"
96+
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
97+
credentials {
98+
username = sonatypeUsername
99+
password = sonatypePassword
100+
}
101+
}
102+
}
103+
}
104+
105+
signing {
106+
isRequired = sonatypeUsername != null && sonatypePassword != null
107+
useInMemoryPgpKeys(signingKey, signingPassword)
108+
sign(publishing.publications)
109+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
package rsocketbuild
18+
19+
@Suppress("ConstPropertyName")
20+
object OptIns {
21+
const val ExperimentalStdlibApi = "kotlin.ExperimentalStdlibApi"
22+
const val ExperimentalCoroutinesApi = "kotlinx.coroutines.ExperimentalCoroutinesApi"
23+
const val DelicateCoroutinesApi = "kotlinx.coroutines.DelicateCoroutinesApi"
24+
25+
const val TransportApi = "io.rsocket.kotlin.TransportApi"
26+
const val ExperimentalMetadataApi = "io.rsocket.kotlin.ExperimentalMetadataApi"
27+
const val ExperimentalStreamsApi = "io.rsocket.kotlin.ExperimentalStreamsApi"
28+
const val RSocketLoggingApi = "io.rsocket.kotlin.RSocketLoggingApi"
29+
}

0 commit comments

Comments
 (0)