From 32b1498c1b1451823bcb22df8a7a91f08dccf09f Mon Sep 17 00:00:00 2001 From: G'lek Tarssza Date: Thu, 12 Mar 2026 07:49:40 -0600 Subject: [PATCH] feat(gradle): Aliased to `gradlew` as well as `gradle`. Added this change to the `README.md`. Also cleaned/reworded up the `README.md` a touch. --- plugins/gradle/README.md | 20 ++++++++++++++------ plugins/gradle/gradle.plugin.zsh | 5 +++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/plugins/gradle/README.md b/plugins/gradle/README.md index 3756db0dc..635b89d39 100644 --- a/plugins/gradle/README.md +++ b/plugins/gradle/README.md @@ -11,17 +11,25 @@ plugins=(... gradle) ## Usage This plugin creates a function called `gradle-or-gradlew`, which is aliased -to `gradle`, which is used to determine whether the current project directory -has a gradlew file. If `gradlew` is present it will be used, otherwise `gradle` -is used instead. Gradle tasks can be executed directly without regard for -whether it is `gradle` or `gradlew`. It also supports being called from -any directory inside the root project directory. +to `gradle` and `gradlew`. This function is is used to determine whether the +current project directory has a `gradlew` wrapper file. If this file is present +it will be used, otherwise the `gradle` binary from the system environment is +used instead. Gradle tasks can be executed directly without regard for whether +it is the environment `gradle` or the `gradlew` wrapper being invoked. It also +supports being called from any directory inside the root directory of a Gradle +project. Examples: ```zsh +# Enter project directory +cd /my/gradle/project +# Will call `gradlew` if present or `gradle` if not gradle test -gradle build +# Enter a sub-directory of the project directory +cd my/sub/directory +# Will call `gradlew` from `/my/gradle/project` if present or `gradle` if not +gradlew build ``` ## Completion diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index dacc46478..e8ea0a403 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -13,9 +13,9 @@ function gradle-or-gradlew() { dir="${dir:h}" done - # if gradlew found, run it instead of gradle + # if local gradle wrapper found, run it instead of gradle if [[ -f "$project_root/gradlew" ]]; then - echo "executing gradlew instead of gradle" + echo "executing local gradle wrapper instead of gradle" "$project_root/gradlew" "$@" else command gradle "$@" @@ -23,4 +23,5 @@ function gradle-or-gradlew() { } alias gradle=gradle-or-gradlew +alias gradlew=gradle-or-gradlew compdef _gradle gradle-or-gradlew