[Android] Gradle build: allow forcing deterministic builds
Nicolas Pomepuy
git at videolan.org
Fri May 16 13:38:22 UTC 2025
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu May 15 09:17:47 2025 +0200| [deabfc77778a67ca1edfe3f87571ee34c4ba52fc] | committer: Duncan McNamara
Gradle build: allow forcing deterministic builds
Fixes #3215
Deterministic builds can be forced by using
-PforceDeterministic=true -PforcedHostName=HostName
> https://code.videolan.org/videolan/vlc-android/commit/deabfc77778a67ca1edfe3f87571ee34c4ba52fc
---
application/vlc-android/build.gradle | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/application/vlc-android/build.gradle b/application/vlc-android/build.gradle
index 179fd13547..daf4a9edd7 100644
--- a/application/vlc-android/build.gradle
+++ b/application/vlc-android/build.gradle
@@ -20,8 +20,8 @@ android {
defaultConfig {
- resValue "string", "build_time", buildTime()
- resValue "string", "build_host", hostName()
+ resValue "string", "build_time", buildTime(project)
+ resValue "string", "build_host", hostName(project)
resValue "string", "build_revision", revision()
resValue "string", "changelog", changelog()
resValue "string", "dav1d_version", dav1dVersion()
@@ -235,11 +235,25 @@ dependencies {
}
-static def buildTime() {
+static def buildTime(project) {
+ if (project.hasProperty('forceDeterministic')) {
+ def code = new ByteArrayOutputStream()
+ project.exec {
+ commandLine 'git', 'show', '--no-patch', '--format=%cd' , '--date=format-local:%Y-%m-%d'
+ standardOutput = code
+ }
+ return code.toString()
+ }
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
-static def hostName() {
+static def hostName(project) {
+ if (project.hasProperty('forceDeterministic')) {
+ if (project.hasProperty('forcedHostName')) {
+ return project.findProperty("forcedHostName")
+ }
+ return 'Unknown'
+ }
return "${System.getProperty("user.name")}@${InetAddress.localHost.hostName}"
}
More information about the Android
mailing list