Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the multiplatform configuration #3246

Merged
merged 3 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sqldelight-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,18 @@ test {
":dialects:sqlite-3-38:publishAllPublicationsToInstallLocallyRepository",
":sqldelight-compiler:dialect:publishAllPublicationsToInstallLocallyRepository",
":runtime:runtime:publishKotlinMultiplatformPublicationToInstallLocallyRepository",
":runtime:runtime:publishIosArm64PublicationToInstallLocallyRepository",
":runtime:runtime:publishJvmPublicationToInstallLocallyRepository",
":runtime:runtime:publishJsPublicationToInstallLocallyRepository",
":runtime:runtime-async:publishKotlinMultiplatformPublicationToInstallLocallyRepository",
":runtime:runtime-async:publishJvmPublicationToInstallLocallyRepository",
":runtime:runtime-async:publishJsPublicationToInstallLocallyRepository",
":runtime:internal:publishKotlinMultiplatformPublicationToInstallLocallyRepository",
":runtime:internal:publishIosArm64PublicationToInstallLocallyRepository",
":runtime:internal:publishJvmPublicationToInstallLocallyRepository",
":runtime:internal:publishJsPublicationToInstallLocallyRepository",
":runtime:shared:publishKotlinMultiplatformPublicationToInstallLocallyRepository",
":runtime:shared:publishIosArm64PublicationToInstallLocallyRepository",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file are unrelated and were required for some Gradle tests to pass on my mac. I'm assuming they pass on CI because they're run on linux and therefore the task are disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well.. publishIosArm64PublicationToInstallLocallyRepository fails on linux. I reverted this part. Will look into it in a separate PR

":runtime:shared:publishJvmPublicationToInstallLocallyRepository",
":runtime:shared:publishJsPublicationToInstallLocallyRepository",
":drivers:android-driver:publishAllPublicationsToInstallLocallyRepository",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import java.io.File

/**
Expand Down Expand Up @@ -61,31 +58,16 @@ private fun KotlinMultiplatformExtension.sources(): List<Source> {
// For multiplatform we only support SQLDelight in commonMain - to support other source sets
// we would need to generate expect/actual SQLDelight code which at least right now doesn't
// seem like there is a use case for. However this code is capable of running on any Target type.
val target = targets.single { it is KotlinMetadataTarget }
return target.compilations.mapNotNull { compilation ->
if (compilation.name.endsWith(suffix = "Test", ignoreCase = true)) {
// TODO: If we can include these compilations as sqldelight compilation units, we solve
// the testing problem. However there's no api to get the main compilation for a test
// compilation, except for native where KotlinNativeCompilation has a
// "friendCompilationName" which is the main compilation unit. There looks to be
// nothing for the other compilation units, but we should revisit later to see if
// theres a way to accomplish this.
return@mapNotNull null
}
if (target is KotlinMetadataTarget && compilation.name == "commonMain") {
// In Kotlin 1.6.20 the metadata target now has two compilations for unknown reasons.
return@mapNotNull null
}
val targetName = if (target is KotlinMetadataTarget) "common" else target.name
return listOf(
Source(
type = target.platformType,
nativePresetName = (target as? KotlinNativeTarget)?.preset?.name,
name = "$targetName${compilation.name.capitalize()}",
variantName = (compilation as? KotlinJvmAndroidCompilation)?.name,
sourceDirectorySet = compilation.defaultSourceSet.kotlin,
sourceSets = compilation.allKotlinSourceSets.map { it.name },
type = KotlinPlatformType.common,
nativePresetName = null,
name = "commonMain",
variantName = "commonMain",
sourceDirectorySet = sourceSets.getByName("commonMain").kotlin,
sourceSets = listOf("commonMain"),
)
}
)
}

private fun BaseExtension.sources(): List<Source> {
Expand Down