-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
47 lines (41 loc) · 1.87 KB
/
build.gradle.kts
File metadata and controls
47 lines (41 loc) · 1.87 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.rust.android) apply false
}
// Remove these lines:
// var versionName = "1.0.0"
// var versionCode = 210
import org.gradle.api.provider.Property
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
abstract class GetVersionTask : DefaultTask() {
@get:Input
abstract val versionName: Property<String>
@TaskAction
fun writeVersion() {
val versionFile = project.layout.projectDirectory.file("app/build/version.txt").asFile
versionFile.parentFile.mkdirs()
versionFile.writeText(versionName.get())
}
}
tasks.register<GetVersionTask>("getVersion") {
// Value comes from gradle.properties; falls back to 1.0.0 if not set.
versionName.set(providers.gradleProperty("APP_VERSION_NAME").orElse("1.0.0"))
}
// You can still set these for legacy use by submodules or scripts:
rootProject.ext.set("appVersionName", providers.gradleProperty("APP_VERSION_NAME").orElse("1.6.8").get())
rootProject.ext.set("appVersionCode", providers.gradleProperty("APP_VERSION_CODE").orElse("324").get().toInt())
rootProject.ext.set("applicationId", "me.eternal.purrfectsnap")
// buildHash: when PurrfectSnap or Snapchat is updated, mappings become outdated and auto-regenerate.
// Include version code so each release has a different hash; use random for uniqueness within same version.
rootProject.ext.set(
"buildHash",
(properties["debug_build_hash"] as String?)
?: "${rootProject.ext["appVersionCode"]}_${java.security.SecureRandom()
.nextLong(Long.MAX_VALUE / 1000L, Long.MAX_VALUE)
.toString(16)}"
)