-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
73 lines (64 loc) · 2.12 KB
/
build.gradle.kts
File metadata and controls
73 lines (64 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import org.gradle.internal.extensions.stdlib.capitalized
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
plugins {
id("io.github.smyrgeorge.sqlx4k.multiplatform.binaries")
alias(libs.plugins.ksp) // We need the KSP plugin for code-generation.
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation(project(":sqlx4k-sqlite"))
}
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
}
}
}
ksp {
arg("dialect", "sqlite")
arg("output-package", "io.github.smyrgeorge.sqlx4k.examples.sqlite")
arg("validate-sql-schema", "false")
arg("schema-migrations-path", "./db/migrations")
}
dependencies {
add("kspCommonMainMetadata", project(":sqlx4k-codegen"))
}
targetsOf(project).forEach {
project.tasks.getByName("compileKotlin$it") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
tasks.withType<KotlinCompilationTask<*>> {
dependsOn("kspCommonMainKotlinMetadata")
}
fun targetsOf(project: Project): List<String> {
val os = DefaultNativePlatform.getCurrentOperatingSystem()
val arch = DefaultNativePlatform.getCurrentArchitecture()
val osString = when {
os.isLinux -> "Linux"
os.isMacOsX -> "Macos"
os.isWindows -> "Mingw"
else -> throw GradleException("Unsupported operating system: $os")
}
val archString = when {
arch.isArm64 -> "Arm64"
arch.isAmd64 -> "X64"
else -> throw GradleException("Unsupported architecture: $arch")
}
val defaultTarget = "$osString$archString"
return (project.properties["targets"] as? String)?.let {
when (it) {
"all" -> listOf(
"IosArm64",
"AndroidNativeX64",
"AndroidNativeArm64",
"MacosArm64",
"LinuxArm64",
"LinuxX64",
"MingwX64"
)
else -> it.split(",").map { t -> t.trim().capitalized() }
}
} ?: listOf(defaultTarget) // Default for local development.
}