mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +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() {
|
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() {
|
||||||
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() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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)
|
||||||
|
|
Loading…
Reference in a new issue