9bd0ac9b005189edceb0ac53f361fcc020f8e6b6

Author
Arthur Maltson <arthur@maltson.com>
Committer
GitHub <noreply@github.com>
Date

Message

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

Diff

This diff is truncated to protect this page.

 1diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
 2index 27d63a6f9cd0b69c99cb5878015306292f8592ec..e32729aa69c8e19776ff526490e7925826559879 100644
 3--- a/plugins/mvn/mvn.plugin.zsh
 4+++ b/plugins/mvn/mvn.plugin.zsh
 5@@ -1,39 +1,46 @@
 6-# Calls ./mvnw if found, otherwise execute the original mvn
 7+# Calls mvnw if found in the current project, otherwise execute the original mvn
 8 mvn-or-mvnw() {
 9-	if [ -x ./mvnw ]; then
10-		echo "executing mvnw instead of mvn"
11-		./mvnw "$@"
12-	else
13-		command mvn "$@"
14-	fi
15+  local dir="$PWD"
16+  while [[ ! -x "$dir/mvnw" && "$dir" != / ]]; do
17+    dir="${dir:h}"
18+  done
19+
20+  if [[ -x "$dir/mvnw" ]]; then
21+    echo "Running \`$dir/mvnw\`..." >&2
22+    "$dir/mvnw" "$@"
23+    return $?
24+  fi
25+
26+  command mvn "$@"
27 }
28 
29 # Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
30 mvn-color() {
31-	local BOLD=$(echoti bold)
32-	local TEXT_RED=$(echoti setaf 1)
33-	local TEXT_GREEN=$(echoti setaf 2)
34-	local TEXT_YELLOW=$(echoti setaf 3)
35-	local TEXT_BLUE=$(echoti setaf 4)
36-	local TEXT_WHITE=$(echoti setaf 7)
37-	local RESET_FORMATTING=$(echoti sgr0)
38-	(
39-	# Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
40-	unset LANG
41-	LC_CTYPE=C mvn "$@" | sed \
42-		-e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
43-		-e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \
44-		-e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
45-		-e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
46-		-e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \