Currently I’m using gradle + BuildConfig.java to pass information into my app and if I’m reading the docs and warnings right, this functionality is disappearing with gradle 9.
I’m currently at gradle 8.4. My app build.gradle looks like:
android {
...
buildFeatures {
buildConfig = true
}
defaultConfig {
...
// use git to get the current branch identifier.
def branchName = "git rev-parse --abbrev-ref HEAD".execute().text.trim()
def commitDate = "utils/gitCommitDate.pl".execute().text.trim()
def buildId = "git rev-parse HEAD".execute().text.trim()
buildConfigField 'long', 'BUILD_TIMESTAMP',
String.format("0x%08xL", System.currentTimeMillis())
buildConfigField "String", "BRANCH_NAME", ""$branchName""
buildConfigField "String", "BUILD_ID", ""$buildId""
buildConfigField "String", "COMMIT_DATE", ""$commitDate""
}
...
}
...
I execute system calls or a PERL script to set the custom build config fields.
Gradle then adds these custom fields to BuildConfig.java and I use the package manager to read the values:
BuildConfig.APPLICATION_ID,
BuildConfig.VERSION_CODE,
BuildConfig.VERSION_NAME,
BuildConfig.BRANCH_NAME,
BuildConfig.COMMIT_DATE,
If I’m reading the warnings and the docs right, BuildConfig will be going away with Gradle 9.
After Gradle 9, how can get this info and pass it into the app?