mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-12 20:21:02 +01:00
feat(mvn): support using mvnw
in multi-module projects (#9413)
This commit is contained in:
parent
f82aa81931
commit
9bd0ac9b00
1 changed files with 269 additions and 262 deletions
|
@ -1,11 +1,17 @@
|
|||
# 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)
|
||||
|
|
Loading…
Reference in a new issue