Skip to content

Commit

Permalink
build logic cleanup step 2
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
whyoleg committed Mar 2, 2024
1 parent b822227 commit cd050d5
Show file tree
Hide file tree
Showing 35 changed files with 492 additions and 733 deletions.
132 changes: 132 additions & 0 deletions build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts
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 } }
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/

plugins {
id("rsocketbuild.target.native.nix")
id("rsocketbuild.multiplatform-base")
id("rsocketbuild.publication")
}

kotlin {
mingwX64()
explicitApi()
}
49 changes: 0 additions & 49 deletions build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions build-logic/src/main/kotlin/rsocketbuild.target.all.gradle.kts

This file was deleted.

20 changes: 0 additions & 20 deletions build-logic/src/main/kotlin/rsocketbuild.target.js.all.gradle.kts

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions build-logic/src/main/kotlin/rsocketbuild.target.js.node.gradle.kts

This file was deleted.

49 changes: 0 additions & 49 deletions build-logic/src/main/kotlin/rsocketbuild.target.jvm.gradle.kts

This file was deleted.

Loading

0 comments on commit cd050d5

Please sign in to comment.