Last active
November 5, 2025 16:36
-
-
Save HSGamer/4d89c0b6aedfd06a7c3d60baf93a539f to your computer and use it in GitHub Desktop.
The Bash script to update versions of all modules in a multi-module Maven projects
This file contains hidden or 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
| #!/bin/bash | |
| MODULE_DIRS=() | |
| # Function to recursively find valid pom.xml files | |
| find_modules() { | |
| local dir="$1" | |
| POM_FILE="$dir/pom.xml" | |
| if [[ -f "$POM_FILE" ]] && grep -q '<packaging>pom</packaging>' "$POM_FILE"; then | |
| MODULE_DIRS+=("$dir") | |
| for subdir in "$dir"/*/; do | |
| [[ -d "$subdir" ]] || continue | |
| find_modules "$subdir" # Recursively check for sub-modules | |
| done | |
| fi | |
| } | |
| # Start searching from current directory | |
| find_modules "$(pwd)" | |
| # Run Maven command for each valid module directory | |
| for dir in "${MODULE_DIRS[@]}"; do | |
| echo "Updating versions for module in directory: $dir" | |
| cd "$dir" || exit | |
| mvn -N versions:update-child-modules -DgenerateBackupPoms=false | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment