-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
216 lines (171 loc) · 5.49 KB
/
build.gradle.kts
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
import org.jetbrains.kotlin.konan.properties.hasProperty
val artifactId = "cinematic.journey"
val groupId = "com.wizbii"
val packageId = "$groupId.$artifactId"
val appVersionName = "0.0.15-SNAPSHOT"
val appVersionCode = appVersionName
.removeSuffix("-SNAPSHOT")
.split('.')
.joinToString("") {
it.padStart(3, '0')
}
.toInt()
val localProperties = gradleLocalProperties(rootDir)
group = groupId
version = appVersionName
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.build.config)
alias(libs.plugins.jetbrains.compose)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.plugin.atomicfu)
alias(libs.plugins.kotlin.plugin.compose)
alias(libs.plugins.kotlin.plugin.serialization)
alias(libs.plugins.kotlinx.atomicfu)
alias(libs.plugins.sqldelight)
alias(libs.plugins.versions)
}
kotlin {
jvmToolchain(libs.versions.java.get().toInt())
androidTarget()
iosArm64()
iosSimulatorArm64()
iosX64()
jvm("desktop") {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
mainRun {
mainClass.set("$packageId.MainKt")
}
}
@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
common {
group("mobile") {
withAndroidTarget()
withIos()
}
}
}
targets.filterIsInstance<KotlinNativeTarget>().forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "ComposeApp"
}
}
sourceSets.configureEach {
languageSettings {
optIn("androidx.compose.foundation.ExperimentalFoundationApi")
optIn("androidx.compose.material3.ExperimentalMaterial3Api")
if (name.startsWith("ios")) {
optIn("kotlinx.cinterop.BetaInteropApi")
optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
}
}
}
repositories {
mavenCentral()
google()
}
dependencies {
"commonMainApi"(libs.bundles.common.main.api)
"commonMainImplementation"(libs.bundles.common.main.implementation)
"androidMainImplementation"(libs.bundles.android.main)
"iosMainImplementation"(libs.bundles.ios.main)
"desktopMainImplementation"(libs.bundles.desktop.main)
"commonTestImplementation"(libs.bundles.common.test)
"desktopTestImplementation"(libs.bundles.desktop.test)
"desktopMainImplementation"(compose.desktop.currentOs)
}
buildConfig {
useKotlinOutput {
topLevelConstants = true
}
packageName = packageId
if (!localProperties.hasProperty("tmdb.api.key")) {
throw GradleException("TMDB API key not defined. Set the tmdb.api.key in your project's local properties file at '${rootDir}/local.properties'.")
}
buildConfigField(
name = "TMDB_API_KEY",
value = localProperties.getProperty("tmdb.api.key"),
)
}
tasks.withType<KotlinJvmTest> {
useJUnitPlatform()
}
android {
namespace = packageId
compileSdk = libs.versions.android.sdk.compile.get().toInt()
defaultConfig {
applicationId = packageId
minSdk = libs.versions.android.sdk.min.get().toInt()
targetSdk = libs.versions.android.sdk.target.get().toInt()
versionCode = appVersionCode
versionName = appVersionName
}
signingConfigs.create("release") {
storeFile = file("upload-keystore.jks")
storePassword = localProperties.getProperty("android.upload.keystore.passphrase")
keyAlias = "upload"
keyPassword = localProperties.getProperty("android.upload.keystore.passphrase")
}
compileOptions {
val javaVersion = JavaVersion.toVersion(libs.versions.java.get())
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
signingConfig = signingConfigs.getByName("release")
}
}
}
compose.desktop {
application {
mainClass = "$packageId.MainKt"
buildTypes.release.proguard.isEnabled.set(false)
}
}
tasks.wrapper {
gradleVersion = libs.versions.gradle.get()
}
sqldelight {
databases {
create("Database") {
packageName.set("$packageId.data")
}
}
}
task("setXcodeVersion") {
group = "xcode"
doLast {
exec {
workingDir("xcode")
commandLine("agvtool", "new-version", "-all", appVersionCode)
}
exec {
workingDir("xcode")
commandLine("agvtool", "new-marketing-version", appVersionName)
}
}
}
tasks.withType<DependencyUpdatesTask> {
fun isUnstable(version: String): Boolean {
val lowerVersion = version.lowercase()
val keywords = listOf("alpha", "beta", "dev", "RC").map(String::lowercase)
for (keyword in keywords)
if (keyword in lowerVersion)
return true
return false
}
rejectVersionIf {
isUnstable(candidate.version) && !isUnstable(currentVersion)
}
}