forked from bmax121/APatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
48 lines (40 loc) · 1.3 KB
/
build.gradle.kts
File metadata and controls
48 lines (40 loc) · 1.3 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
plugins {
alias(libs.plugins.agp.app) apply false
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.kotlin.compose.compiler) apply false
}
project.ext.set("kernelPatchVersion", "0.13.0")
val androidMinSdkVersion by extra(26)
val androidTargetSdkVersion by extra(36)
val androidCompileSdkVersion by extra(36)
val androidBuildToolsVersion by extra("36.1.0")
val androidCompileNdkVersion by extra("29.0.14206865")
val managerVersionCode by extra(getVersionCode())
val managerVersionName by extra(getVersionName())
val branchName by extra(getBranch())
fun Project.exec(command: String) = providers.exec {
commandLine(command.split(" "))
}.standardOutput.asText.get().trim()
fun getGitCommitCount(): Int {
return exec("git rev-list --count HEAD").trim().toInt()
}
fun getGitDescribe(): String {
return exec("git rev-parse --verify --short HEAD").trim()
}
fun getVersionCode(): Int {
val commitCount = getGitCommitCount()
val major = 1
return major * 10000 + commitCount + 200
}
fun getBranch(): String {
return exec("git rev-parse --abbrev-ref HEAD").trim()
}
fun getVersionName(): String {
return getGitDescribe()
}
tasks.register("printVersion") {
doLast {
println("Version code: $managerVersionCode")
println("Version name: $managerVersionName")
}
}