-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
77 lines (65 loc) · 2.75 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
// 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.android.kotlin) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kotlin.ksp) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.androidTest) apply false
alias(libs.plugins.google.gms) apply false
alias(libs.plugins.firebase.crashlytics) apply false
}
val isGoogleMobileServicesBuild by extra {
gradle.startParameter.taskNames.none { task -> task.contains("foss", ignoreCase = true) }
}
val commitSignature = providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText.get().substringBefore("\n")
sealed class Version(
open val versionMajor: Int,
val versionMinor: Int,
val versionPatch: Int,
val versionBuild: Int = 0,
val commitId: String = ""
) {
abstract fun toVersionName(): String
fun toVersionCode(): Int {
val minorExtraDigit = if (versionMinor > 9) {
(versionMinor / 10).toString()
} else {
""
}
return "$versionMajor$minorExtraDigit$versionPatch$versionBuild".toInt()
}
class Stable(versionMajor: Int, versionMinor: Int, versionPatch: Int) :
Version(versionMajor, versionMinor, versionPatch) {
override fun toVersionName(): String = "${versionMajor}.${versionMinor}.${versionPatch}"
}
class ReleaseCandidate(
versionMajor: Int, versionMinor: Int, versionPatch: Int, versionBuild: Int
) : Version(versionMajor, versionMinor, versionPatch, versionBuild) {
override fun toVersionName(): String =
"${versionMajor}.${versionMinor}.${versionPatch}-rc.$versionBuild"
}
class Beta(versionMajor: Int, versionMinor: Int, versionPatch: Int, versionBuild: Int) :
Version(versionMajor, versionMinor, versionPatch, versionBuild) {
override fun toVersionName(): String =
"${versionMajor}.${versionMinor}.${versionPatch}-beta.$versionBuild"
}
class Alpha(
versionMajor: Int, versionMinor: Int, versionPatch: Int, commitId: String
) : Version(versionMajor, versionMinor, versionPatch, commitId = commitId) {
override fun toVersionName(): String =
"${versionMajor}.${versionMinor}.${versionPatch}-alpha.$commitId"
}
}
val currentVersion: Version = Version.Beta(
versionMajor = 1,
versionMinor = 0,
versionPatch = 0,
versionBuild = 8
)
val versionCode by extra(currentVersion.toVersionCode())
val versionName by extra(currentVersion.toVersionName())