From f241ccaeb58ecf662693c85974f52f08ccf9a1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Sun, 30 Apr 2023 20:37:47 +0100 Subject: [PATCH] control fixes --- .../kotlin/convention.kotlin-mpp.gradle.kts | 23 +++++++++++++++++++ .../convention.publishing-mpp.gradle.kts | 13 +---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/build-conventions/src/main/kotlin/convention.kotlin-mpp.gradle.kts b/build-conventions/src/main/kotlin/convention.kotlin-mpp.gradle.kts index a7f02f3..ce34a6a 100644 --- a/build-conventions/src/main/kotlin/convention.kotlin-mpp.gradle.kts +++ b/build-conventions/src/main/kotlin/convention.kotlin-mpp.gradle.kts @@ -1,4 +1,10 @@ +import Env.CI +import Env.SANDBOX import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation +import util.buildHost +import util.enabled +import util.mainHost plugins { id("convention.base") @@ -8,4 +14,21 @@ plugins { kotlin { @OptIn(ExperimentalKotlinGradlePluginApi::class) targetHierarchy.default() + + targets.all target@{ + val control = Action { + onlyIf { + !CI || this@target.enabled || (SANDBOX && this@target.buildHost == mainHost) + } + } + compilations.all compilation@{ + compileTaskProvider.configure(control) + + if (this@compilation is KotlinNativeCompilation) { + this@compilation.cinterops.all { + tasks.named(interopProcessingTaskName, control) + } + } + } + } } diff --git a/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts b/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts index eed2ef7..4a5e6ff 100644 --- a/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts +++ b/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts @@ -1,7 +1,6 @@ import Env.CI import Env.SANDBOX import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation import org.jetbrains.kotlin.konan.target.HostManager import util.buildHost import util.enabled @@ -29,21 +28,11 @@ kotlin { } targets.all target@{ - val control = Action { + configurePublishTasks(this@target.name) { onlyIf { !CI || this@target.enabled || (SANDBOX && this@target.buildHost == mainHost) } } - compilations.all compilation@{ - compileTaskProvider.configure(control) - - if (this@compilation is KotlinNativeCompilation) { - this@compilation.cinterops.all { - tasks.named(interopProcessingTaskName, control) - } - } - configurePublishTasks(this@target.name, control) - } if (this@target is KotlinAndroidTarget && (!CI || this@target.enabled || SANDBOX)) this@target.publishLibraryVariants("release", "debug")