Skip to content

Instantly share code, notes, and snippets.

@race604
Created August 20, 2023 07:27
Show Gist options
  • Save race604/12b509292d36b7ae4e85d75221745302 to your computer and use it in GitHub Desktop.
Save race604/12b509292d36b7ae4e85d75221745302 to your computer and use it in GitHub Desktop.
Auto find the `gradew` script and run gradle commands
# 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 "$@"
}
@race604
Copy link
Author

race604 commented Aug 20, 2023

Add the code snippet into .zhsrc or .zprofile, then we can run the following command in any sub module of any java project

gd classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment