Created
August 20, 2023 07:27
-
-
Save race604/12b509292d36b7ae4e85d75221745302 to your computer and use it in GitHub Desktop.
Auto find the `gradew` script and run gradle commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find file in current and parent dir recursively | |
function find_up { | |
path=$(pwd) | |
while [[ "$path" != "" && ! -e "$path/$1" ]]; do | |
path=${path%/*} | |
done | |
if [[ ! -e "$path/$1" ]] | |
then | |
echo "ERROR: $1 not found" 1>&2 | |
return 1 | |
fi | |
echo "$path"/$1 | |
} | |
function gd { | |
CMD=$(find_up gradlew) | |
if [[ ! "$CMD" ]]; then | |
return 11 | |
fi | |
echo "CMD: $CMD" | |
$CMD "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the code snippet into
.zhsrc
or.zprofile
, then we can run the following command in any sub module of any java project