Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
Loading