Add build version option to prefix git hash with custom version property (#7222)

* Add build version option to prefix git hash with custom version property
* Refactor to make appending the git hash a boolean property. Include a commented-out example of how to use the properties in the gradle file

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
pull/7252/head
Matt Whitehead 5 months ago committed by GitHub
parent 8c04d0ae36
commit 609eb76ba0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      build.gradle
  2. 5
      gradle.properties

@ -934,6 +934,10 @@ def calculateVersion() {
def calVerPattern = ~/\d+\.\d+(\.\d+)?(-.*)?/
if (project.hasProperty('version') && (project.version =~ calVerPattern)) {
if (project.hasProperty('versionappendcommit') && project.versionappendcommit == "true") {
def gitDetails = getGitCommitDetails(7) // Adjust length as needed
return "${project.version}-${gitDetails.hash}"
}
return "${project.version}"
} else {
// If no version is supplied or it doesn't match the semantic versioning, calculate from git

@ -1,4 +1,9 @@
org.gradle.welcome=never
# Optional - set custom build version
# version=24.5.6-acme
# versionappendcommit=true
# Set exports/opens flags required by Google Java Format and ErrorProne plugins. (JEP-396)
org.gradle.jvmargs=-Xmx4g \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \

Loading…
Cancel
Save