Skip to content

Commit

Permalink
remove workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
softartdev committed Apr 9, 2024
1 parent 45a6230 commit 53a231f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,6 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.Companion.COMMON_MAIN_SOURCE_SET_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.Companion.COMMON_TEST_SOURCE_SET_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

val Project.libs
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")

//FIXME https://github.com/cashapp/sqldelight/issues/4523
fun KotlinSourceSetContainer.iosIntermediateSourceSets(vararg iosTargets: KotlinNativeTarget) {
val children: List<Pair<KotlinSourceSet, KotlinSourceSet>> = iosTargets.map { target ->
val main = target.compilations.getByName(MAIN_COMPILATION_NAME).defaultSourceSet
val test = target.compilations.getByName(TEST_COMPILATION_NAME).defaultSourceSet
return@map main to test
}
val parent: Pair<KotlinSourceSet, KotlinSourceSet> = Pair(
first = sourceSets.getByName(COMMON_MAIN_SOURCE_SET_NAME),
second = sourceSets.getByName(COMMON_TEST_SOURCE_SET_NAME)
)
createIntermediateSourceSet("iosMain", children.map { it.first }, parent.first)
createIntermediateSourceSet("iosTest", children.map { it.second }, parent.second)
}

private fun KotlinSourceSetContainer.createIntermediateSourceSet(
name: String,
children: List<KotlinSourceSet>,
parent: KotlinSourceSet
): KotlinSourceSet = sourceSets.maybeCreate(name).apply {
dependsOn(parent)
children.forEach { it.dependsOn(this) }
}
4 changes: 2 additions & 2 deletions ios-compose-kit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.softartdev.notedelight.iosIntermediateSourceSets
import org.gradle.internal.os.OperatingSystem

plugins {
Expand All @@ -10,7 +9,8 @@ compose {
kotlinCompilerPlugin.set(libs.versions.composeCompiler.get())
}
kotlin {
iosIntermediateSourceSets(iosArm64(), iosSimulatorArm64())
iosArm64()
iosSimulatorArm64()
applyDefaultHierarchyTemplate()

cocoapods {
Expand Down
5 changes: 2 additions & 3 deletions shared-compose-ui/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import com.softartdev.notedelight.iosIntermediateSourceSets

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)
Expand All @@ -17,7 +15,8 @@ kotlin {
}
}
androidTarget()
iosIntermediateSourceSets(iosArm64(), iosSimulatorArm64())
iosArm64()
iosSimulatorArm64()
applyDefaultHierarchyTemplate()

sourceSets {
Expand Down
5 changes: 2 additions & 3 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import com.softartdev.notedelight.iosIntermediateSourceSets
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.gradle.convention)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.cocoapods)
alias(libs.plugins.sqlDelight)
Expand Down Expand Up @@ -56,7 +54,8 @@ kotlin {
jvmToolchain(libs.versions.jdk.get().toInt())
jvm()
androidTarget()
iosIntermediateSourceSets(iosArm64(), iosSimulatorArm64())
iosArm64()
iosSimulatorArm64()
applyDefaultHierarchyTemplate()

sourceSets {
Expand Down

0 comments on commit 53a231f

Please sign in to comment.