forked from ctripcorp/SQLlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
166 lines (147 loc) · 4.69 KB
/
build.gradle.kts
File metadata and controls
166 lines (147 loc) · 4.69 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.target.HostManager
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)
alias(libs.plugins.vanniktech.maven.publish)
}
val GROUP_ID: String by project
val VERSION: String by project
group = GROUP_ID
version = VERSION
@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
explicitApi()
jvmToolchain(libs.versions.jvm.toolchain.get().toInt())
androidTarget {
publishLibraryVariants("release")
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
}
jvm {
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
macosX64(),
macosArm64(),
watchosArm32(),
watchosArm64(),
watchosX64(),
watchosSimulatorArm64(),
watchosDeviceArm64(),
tvosArm64(),
tvosX64(),
tvosSimulatorArm64(),
linuxX64(),
linuxArm64(),
mingwX64(),
).forEach {
it.setupNativeConfig()
}
compilerOptions {
freeCompilerArgs.addAll("-Xexpect-actual-classes", "-Xcontext-parameters", "-Xnested-type-aliases")
}
sourceSets {
all {
languageSettings {
optIn("kotlin.RequiresOptIn")
}
}
commonTest.dependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.coroutines.test)
}
androidMain.dependencies {
implementation(libs.androidx.annotation)
}
androidInstrumentedTest.dependencies {
implementation(libs.androidx.test.core)
implementation(libs.androidx.test.runner)
implementation(libs.androidx.test.rules)
}
jvmMain.dependencies {
implementation(libs.sqlite.jdbc)
}
}
}
gradle.taskGraph.whenReady {
if (!project.hasProperty("onCICD"))
return@whenReady
tasks.forEach {
when {
it.name.contains("linux", true) -> it.enabled = HostManager.hostIsLinux
it.name.contains("mingw", true) -> it.enabled = HostManager.hostIsMingw
it.name.contains("ios", true)
|| it.name.contains("macos", true)
|| it.name.contains("watchos", true)
|| it.name.contains("tvos", true) -> it.enabled = HostManager.hostIsMac
}
}
}
android {
namespace = "com.ctrip.sqllin.driver"
compileSdk = libs.versions.android.sdk.compile.get().toInt()
defaultConfig {
minSdk = libs.versions.android.sdk.min.get().toInt()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
fun KotlinNativeTarget.setupNativeConfig() {
val main by compilations.getting
val sqlite3 by main.cinterops.creating {
includeDirs("$projectDir/src/include")
}
binaries.all {
linkerOpts += when {
HostManager.hostIsLinux -> listOf("-lsqlite3", "-L$rootDir/libs/linux", "-L/usr/lib/x86_64-linux-gnu", "-L/usr/lib", "-L/usr/lib64")
HostManager.hostIsMingw -> listOf("-Lc:\\msys64\\mingw64\\lib", "-L$rootDir\\libs\\windows", "-lsqlite3")
else -> listOf("-lsqlite3")
}
}
}
mavenPublishing {
publishToMavenCentral()
signAllPublications()
val artifactId = "sqllin-driver"
coordinates(
groupId = GROUP_ID,
artifactId = artifactId,
version = VERSION,
)
pom {
name.set(artifactId)
description.set("Low-level API for SQLite on Kotlin Multiplatform")
val githubURL: String by project
url.set(githubURL)
licenses {
license {
val licenseName: String by project
name.set(licenseName)
val licenseURL: String by project
url.set(licenseURL)
}
}
developers {
developer {
val developerID: String by project
id.set(developerID)
val developerName: String by project
name.set(developerName)
val developerEmail: String by project
email.set(developerEmail)
}
}
scm {
url.set(githubURL)
val scmURL: String by project
connection.set(scmURL)
developerConnection.set(scmURL)
}
}
}