Created
October 30, 2023 06:39
-
-
Save sha1n/d71689d2e53e34699fe24e98b1c251c8 to your computer and use it in GitHub Desktop.
Maven version update utility script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
update_type=$1 | |
maven_args="" | |
invalid_argument() { | |
echo "Error: Invalid argument." | |
echo "Usage: $0 {major|minor|patch}" | |
exit 1 | |
} | |
if [ "$#" -ne 1 ]; then | |
invalid_argument | |
fi | |
# shellcheck disable=SC2016 | |
case $update_type in | |
major) | |
echo "Executing major update commands..." | |
maven_args='versions:set -DnewVersion=\${parsedVersion.nextMajorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion}-\${parsedVersion.qualifier}' | |
;; | |
minor) | |
echo "Executing minor update commands..." | |
maven_args='versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.\${parsedVersion.incrementalVersion}-\${parsedVersion.qualifier}' | |
;; | |
patch) | |
echo "Executing patch update commands..." | |
maven_args='versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-\${parsedVersion.qualifier}' | |
;; | |
*) | |
invalid_argument | |
;; | |
esac | |
eval "mvn build-helper:parse-version ${maven_args}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment