Skip to content

Commit 5505e26

Browse files
committed
Update to Gradle 8.11
Signed-off-by: Leonardo Ledda <leonardoledda@gmail.com>
1 parent e3dfb69 commit 5505e26

File tree

5 files changed

+222
-147
lines changed

5 files changed

+222
-147
lines changed

app/build.gradle.kts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@ plugins {
33
id("org.jetbrains.kotlin.android")
44
}
55

6-
fun getCommitCount(): Int {
7-
val stdout = org.apache.commons.io.output.ByteArrayOutputStream()
8-
project.exec {
9-
commandLine = "git rev-list --count HEAD".split(" ")
10-
standardOutput = stdout
11-
}
12-
return Integer.parseInt(String(stdout.toByteArray()).trim())
6+
fun execCommand(command: String): String? {
7+
val cmd = command.split(" ").toTypedArray()
8+
val process = ProcessBuilder(*cmd)
9+
.redirectOutput(ProcessBuilder.Redirect.PIPE)
10+
.start()
11+
return process.inputStream.bufferedReader().readLine()?.trim()
1312
}
1413

15-
fun getCommitHash(): String {
16-
val stdout = org.apache.commons.io.output.ByteArrayOutputStream()
17-
project.exec {
18-
commandLine = "git rev-parse --short HEAD".split(" ")
19-
standardOutput = stdout
20-
}
21-
return String(stdout.toByteArray()).trim()
14+
val commitCount by project.extra {
15+
execCommand("git rev-list --count HEAD")?.toInt()
16+
?: throw GradleException("Unable to get number of commits. Make sure git is initialized.")
17+
}
18+
19+
val commitHash by project.extra {
20+
execCommand("git rev-parse --short HEAD")
21+
?: throw GradleException(
22+
"Unable to get commit hash. Make sure git is initialized."
23+
)
2224
}
2325

2426
android {
@@ -29,8 +31,8 @@ android {
2931
applicationId = "it.leddaz.revancedupdater"
3032
minSdk = 26
3133
targetSdk = 35
32-
versionCode = getCommitCount()
33-
versionName = "3.6.0 (" + getCommitHash() + ")"
34+
versionCode = commitCount
35+
versionName = "3.6.0 ($commitHash)"
3436
}
3537

3638
buildTypes {

gradle/wrapper/gradle-wrapper.jar

-15.3 KB
Binary file not shown.
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#Mon Oct 07 23:36:08 CEST 2024
2-
distributionBase=GRADLE_USER_HOME
3-
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
5-
zipStoreBase=GRADLE_USER_HOME
6-
zipStorePath=wrapper/dists
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)