Skip to content

Commit

Permalink
control fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetuska committed Apr 30, 2023
1 parent 64d5542 commit f241cca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
23 changes: 23 additions & 0 deletions build-conventions/src/main/kotlin/convention.kotlin-mpp.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -8,4 +14,21 @@ plugins {
kotlin {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
targetHierarchy.default()

targets.all target@{
val control = Action<Task> {
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)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -29,21 +28,11 @@ kotlin {
}

targets.all target@{
val control = Action<Task> {
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")
Expand Down

0 comments on commit f241cca

Please sign in to comment.