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() {
if [ -x ./mvnw ]; then
echo "executing mvnw instead of mvn"
./mvnw "$@"
else
command mvn "$@"
local dir="$PWD"
while [[ ! -x "$dir/mvnw" && "$dir" != / ]]; do
dir="${dir:h}"
done
if [[ -x "$dir/mvnw" ]]; then
echo "Running \`$dir/mvnw\`..." >&2
"$dir/mvnw" "$@"
return $?
fi
command mvn "$@"
}
# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
......@@ -17,6 +23,7 @@ mvn-color() {
local TEXT_BLUE=$(echoti setaf 4)
local TEXT_WHITE=$(echoti setaf 7)
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
unset LANG
......@@ -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"
# 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