-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
78 lines (68 loc) · 2.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
sealed class Version(
open val versionMajor: Int,
val versionMinor: Int,
val versionPatch: Int,
val versionBuild: Int = 0,
val commitId: String = ""
) {
abstract fun toVersionName(): String
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 commitSignature = providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText.get().substringBefore("\n")
val currentVersion: Version = Version.Alpha(
versionMajor = 0,
versionMinor = 3,
versionPatch = 0,
commitId = commitSignature
)
val versionName by extra(currentVersion.toVersionName())
val versionCode by extra(
currentVersion.run {
versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
}
)
buildscript {
repositories {
mavenCentral()
google()
}
}
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlin.ksp) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kotlin.compose) apply false
}
allprojects {
group = "com.github.BobbyESP"
version = versionCode
}
tasks.register("clean", Delete::class) {
delete(rootProject.layout.buildDirectory)
}