Unverified Commit 9bd0ac9b authored by Arthur Maltson's avatar Arthur Maltson Committed by GitHub

feat(mvn): support using `mvnw` in multi-module projects (#9413)

parent f82aa819
# Calls ./mvnw if found, otherwise execute the original mvn # Calls mvnw if found in the current project, otherwise execute the original mvn
mvn-or-mvnw() { mvn-or-mvnw() {
if [ -x ./mvnw ]; then local dir="$PWD"
echo "executing mvnw instead of mvn" while [[ ! -x "$dir/mvnw" && "$dir" != / ]]; do
./mvnw "$@" dir="${dir:h}"
else done
command mvn "$@"
if [[ -x "$dir/mvnw" ]]; then
echo "Running \`$dir/mvnw\`..." >&2
"$dir/mvnw" "$@"
return $?
fi fi
command mvn "$@"
} }
# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800 # Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
...@@ -17,6 +23,7 @@ mvn-color() { ...@@ -17,6 +23,7 @@ mvn-color() {
local TEXT_BLUE=$(echoti setaf 4) local TEXT_BLUE=$(echoti setaf 4)
local TEXT_WHITE=$(echoti setaf 7) local TEXT_WHITE=$(echoti setaf 7)
local RESET_FORMATTING=$(echoti sgr0) local RESET_FORMATTING=$(echoti sgr0)
( (
# Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
unset LANG unset LANG
...@@ -33,7 +40,7 @@ mvn-color() { ...@@ -33,7 +40,7 @@ mvn-color() {
) )
} }
# either use orignal mvn or the mvn wrapper # either use original mvn or the mvn wrapper
alias mvn="mvn-or-mvnw" alias mvn="mvn-or-mvnw"
# Run mvn against the pom found in a project's root directory (assumes a git repo) # Run mvn against the pom found in a project's root directory (assumes a git repo)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment