-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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;
- Loading branch information
Showing
53 changed files
with
832 additions
and
1,054 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,4 +120,4 @@ jobs: | |
--scan | ||
--info | ||
--continue | ||
-Pskip.test | ||
-Prsocketbuild.skipTests=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import org.jetbrains.kotlin.gradle.* | ||
import org.jetbrains.kotlin.gradle.plugin.* | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.* | ||
import org.jetbrains.kotlin.gradle.targets.js.ir.* | ||
import org.jetbrains.kotlin.gradle.targets.jvm.* | ||
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.* | ||
import org.jetbrains.kotlin.gradle.targets.native.tasks.* | ||
import org.jetbrains.kotlin.gradle.tasks.* | ||
import rsocketbuild.* | ||
import rsocketbuild.tests.* | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
} | ||
|
||
@OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
kotlin { | ||
compilerOptions { | ||
// allWarningsAsErrors.set(true) | ||
progressiveMode.set(true) | ||
freeCompilerArgs.add("-Xrender-internal-diagnostic-names") | ||
} | ||
|
||
sourceSets.configureEach { | ||
languageSettings { | ||
if (name.contains("test", ignoreCase = true)) { | ||
optIn(OptIns.ExperimentalStdlibApi) | ||
optIn(OptIns.DelicateCoroutinesApi) | ||
|
||
// rsocket related | ||
optIn(OptIns.TransportApi) | ||
optIn(OptIns.ExperimentalMetadataApi) | ||
optIn(OptIns.ExperimentalStreamsApi) | ||
optIn(OptIns.RSocketLoggingApi) | ||
} | ||
} | ||
} | ||
|
||
targets.withType<KotlinJvmTarget>().configureEach { | ||
compilations.configureEach { | ||
compilerOptions.configure { | ||
freeCompilerArgs.add("-Xjvm-default=all") | ||
} | ||
} | ||
} | ||
|
||
// revisit JS block after WASM support | ||
targets.withType<KotlinJsIrTarget>().configureEach { | ||
whenBrowserConfigured { | ||
testTask { | ||
useKarma { | ||
useConfigDirectory(rootDir.resolve("gradle/js/karma.config.d")) | ||
useChromeHeadless() | ||
} | ||
} | ||
} | ||
whenNodejsConfigured { | ||
testTask { | ||
useMocha { | ||
timeout = "600s" | ||
} | ||
} | ||
} | ||
} | ||
|
||
//setup tests running in RELEASE mode | ||
targets.withType<KotlinNativeTarget>().configureEach { | ||
binaries.test(listOf(NativeBuildType.RELEASE)) | ||
} | ||
targets.withType<KotlinNativeTargetWithTests<*>>().configureEach { | ||
testRuns.create("releaseTest") { | ||
setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE)) | ||
} | ||
} | ||
} | ||
|
||
// for CI mainly | ||
|
||
registerTestAggregationTask( | ||
name = "jvmAllTest", | ||
taskDependencies = { tasks.withType<KotlinJvmTest>() }, | ||
targetFilter = { it.platformType == KotlinPlatformType.jvm } | ||
) | ||
|
||
registerTestAggregationTask( | ||
name = "nativeTest", | ||
taskDependencies = { tasks.withType<KotlinNativeTest>().matching { it.enabled } }, | ||
targetFilter = { it.platformType == KotlinPlatformType.native } | ||
) | ||
|
||
listOf("ios", "watchos", "tvos", "macos").forEach { targetGroup -> | ||
registerTestAggregationTask( | ||
name = "${targetGroup}Test", | ||
taskDependencies = { | ||
tasks.withType<KotlinNativeTest>().matching { | ||
it.enabled && it.name.startsWith(targetGroup, ignoreCase = true) | ||
} | ||
}, | ||
targetFilter = { | ||
it.platformType == KotlinPlatformType.native && it.name.startsWith(targetGroup, ignoreCase = true) | ||
} | ||
) | ||
} | ||
|
||
// on build, link even those binaries, which it's not possible to run | ||
tasks.build { | ||
dependsOn(tasks.withType<KotlinNativeLink>()) | ||
} | ||
|
||
if (providers.gradleProperty("rsocketbuild.skipTests").map(String::toBoolean).getOrElse(false)) { | ||
tasks.withType<AbstractTestTask>().configureEach { onlyIf { false } } | ||
} | ||
|
||
if (providers.gradleProperty("rsocketbuild.skipNativeLink").map(String::toBoolean).getOrElse(false)) { | ||
tasks.withType<KotlinNativeLink>().configureEach { onlyIf { false } } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
build-logic/src/main/kotlin/rsocketbuild.publication.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
val githubUsername: String? by project | ||
val githubPassword: String? by project | ||
|
||
val sonatypeUsername: String? by project | ||
val sonatypePassword: String? by project | ||
|
||
val signingKey: String? by project | ||
val signingPassword: String? by project | ||
|
||
// TODO: refactor publication a bit, so that version in gradle.properties will not contain SNAPSHOT | ||
val versionSuffix = providers.gradleProperty("rsocketbuild.versionSuffix").orNull | ||
if (versionSuffix != null) { | ||
val versionString = project.version.toString() | ||
require(versionString.endsWith("-SNAPSHOT")) | ||
project.version = versionString.replace("-", "-${versionSuffix}-") | ||
println("Current version: ${project.version}") | ||
} | ||
|
||
// empty javadoc for maven central | ||
val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") } | ||
|
||
// this is somewhat a hack because we have a single javadoc artifact which is used for all publications | ||
tasks.withType<Sign>().configureEach { mustRunAfter(javadocJar) } | ||
tasks.withType<AbstractPublishToMaven>().configureEach { mustRunAfter(tasks.withType<Sign>()) } | ||
|
||
publishing { | ||
publications.withType<MavenPublication> { | ||
artifact(javadocJar) | ||
pom { | ||
name.set(project.name) | ||
description.set(provider { | ||
checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" } | ||
}) | ||
url.set("http://rsocket.io") | ||
|
||
licenses { | ||
license { | ||
name.set("The Apache Software License, Version 2.0") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
distribution.set("repo") | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("whyoleg") | ||
name.set("Oleg Yukhnevich") | ||
email.set("whyoleg@gmail.com") | ||
} | ||
developer { | ||
id.set("OlegDokuka") | ||
name.set("Oleh Dokuka") | ||
email.set("oleh.dokuka@icloud.com") | ||
} | ||
} | ||
scm { | ||
connection.set("https://github.com/rsocket/rsocket-kotlin.git") | ||
developerConnection.set("https://github.com/rsocket/rsocket-kotlin.git") | ||
url.set("https://github.com/rsocket/rsocket-kotlin") | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
// TODO: drop github and use sonatype (?) | ||
maven { | ||
name = "github" | ||
url = uri("https://maven.pkg.github.com/rsocket/rsocket-kotlin") | ||
credentials { | ||
username = githubUsername | ||
password = githubPassword | ||
} | ||
} | ||
maven { | ||
name = "sonatype" | ||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") | ||
credentials { | ||
username = sonatypeUsername | ||
password = sonatypePassword | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
isRequired = sonatypeUsername != null && sonatypePassword != null | ||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
sign(publishing.publications) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package rsocketbuild | ||
|
||
@Suppress("ConstPropertyName") | ||
object OptIns { | ||
const val ExperimentalStdlibApi = "kotlin.ExperimentalStdlibApi" | ||
const val ExperimentalCoroutinesApi = "kotlinx.coroutines.ExperimentalCoroutinesApi" | ||
const val DelicateCoroutinesApi = "kotlinx.coroutines.DelicateCoroutinesApi" | ||
|
||
const val TransportApi = "io.rsocket.kotlin.TransportApi" | ||
const val ExperimentalMetadataApi = "io.rsocket.kotlin.ExperimentalMetadataApi" | ||
const val ExperimentalStreamsApi = "io.rsocket.kotlin.ExperimentalStreamsApi" | ||
const val RSocketLoggingApi = "io.rsocket.kotlin.RSocketLoggingApi" | ||
} |
Oops, something went wrong.