Skip to content

Instantly share code, notes, and snippets.

@nomisRev
Created January 5, 2022 18:03
Show Gist options
  • Save nomisRev/dfa04f955798b0a8c107e2a564e46487 to your computer and use it in GitHub Desktop.
Save nomisRev/dfa04f955798b0a8c107e2a564e46487 to your computer and use it in GitHub Desktop.
Gradle Kotlin MPP appleTest task
// ./gradlew runs tests for all configured Apple targets
val appleTest = tasks.create("appleTest")
subprojects {
afterEvaluate {
val appleTargets = setOf("tvos", "watchos", "ios", "macos")
extensions.findByType<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension>()
?.sourceSets
?.filter { appleTargets.any { target -> it.name.contains(target) } && it.name.contains("Test") }
?.forEach {
tasks.findByName(it.name)?.let { task ->
appleTest.dependsOn(task)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment