-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
109 lines (93 loc) · 3.45 KB
/
build.gradle.kts
File metadata and controls
109 lines (93 loc) · 3.45 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.jetbrains.kotlin.jvm) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.android.kotlin.multiplatform.library) apply false
alias(libs.plugins.android.lint) apply false
alias(libs.plugins.buildconfig) apply false
alias(libs.plugins.ktor) apply false
alias(libs.plugins.kotlinSerialization) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.skie) apply false
}
// The version number of the project.
//
// For a tagged release, projectVersionNext should be blank and the next commit
// following the release should bump it to the next version number.
//
val projectVersionLast: String? = null
val projectVersionNext: String = "0.1.0"
val appName: String by extra {
System.getenv("MULTIPAZ_WALLET_APP_NAME")
?: "Multipaz Wallet Dev"
}
val updateUrl: String by extra {
System.getenv("MULTIPAZ_WALLET_UPDATE_URL") ?: ""
}
val updateWebsite: String by extra {
System.getenv("MULTIPAZ_WALLET_UPDATE_WEBSITE") ?: ""
}
// This must be of the form https://hostname.example.com, no trailing path allowed.
val backendUrl: String by extra {
System.getenv("MULTIPAZ_WALLET_BACKEND_URL")
?: "https://dev.wallet.multipaz.org"
}
val backendClientId: String by extra {
System.getenv("MULTIPAZ_WALLET_BACKEND_CLIENT_ID")
?: "1016113070986-54k257ap3h8hc40qm9kbl5lmhppjfel1.apps.googleusercontent.com"
}
val backendSecret: String by extra {
System.getenv("MULTIPAZ_WALLET_BACKEND_SECRET")
?: "1234567890"
}
val developerModeAvailable: Boolean by extra {
val str = System.getenv("MULTIPAZ_WALLET_DEVELOPER_MODE_AVAILABLE")
str?.let {
if (it.lowercase() == "false" || it == "0") {
return@extra false
}
}
true
}
// For `versionCode` we just use the number of commits.
val projectVersionCode: Int by extra {
lazy {
runCommand(listOf("git", "rev-list", "HEAD", "--count")).toInt()
}.value
}
tasks.register("printVersionName") {
doLast {
println(projectVersionName)
}
}
private fun runCommand(args: List<String>): String {
return providers.exec {
commandLine(args)
}.standardOutput.asText.get().trim()
}
// Generate a project version meeting the requirements of Semantic Versioning 2.0.0
// according to https://semver.org/
//
// Essentially, for tagged releases use the version number e.g. "0.91.0". Otherwise use
// the next version number with a pre-release string set to "pre.N.H" where N is the
// number of commits since the last version and H is the short commit hash of the
// where we cut the pre-release from. Example: 0.91.0-pre.48.574b479c
//
val projectVersionName: String by extra {
lazy {
if (projectVersionNext.isEmpty()) {
projectVersionLast!!
} else {
val numCommitsSinceTag =
if (projectVersionLast != null) {
runCommand(listOf("git", "rev-list", "${projectVersionLast}..", "--count"))
} else {
runCommand(listOf("git", "rev-list", "HEAD", "--count"))
}
val commitHash = runCommand(listOf("git", "rev-parse", "--short", "HEAD"))
projectVersionNext + "-pre.${numCommitsSinceTag}.${commitHash}"
}
}.value
}