-
-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e712342
commit b430b69
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Gradle plugin | ||
|
||
This plugin adds completions and aliases for [Gradle](https://gradle.org/). | ||
|
||
To use it, add `gradle` to the plugins array in your bashrc file: | ||
|
||
```bash | ||
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. | ||
|
||
Examples: | ||
|
||
```bash | ||
gradle test | ||
gradle build | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#! bash oh-my-bash.module | ||
|
||
function gradle-or-gradlew() { | ||
# find project root | ||
# taken from https://github.com/gradle/gradle-completion | ||
local dir="$PWD" project_root="$PWD" | ||
while [[ "$dir" != / ]]; do | ||
if [[ -x "$dir/gradlew" ]]; then | ||
project_root="$dir" | ||
break | ||
fi | ||
dir="${dir:h}" | ||
done | ||
|
||
# if gradlew found, run it instead of gradle | ||
if [[ -f "$project_root/gradlew" ]]; then | ||
echo "executing gradlew instead of gradle" | ||
"$project_root/gradlew" "$@" | ||
else | ||
command gradle "$@" | ||
fi | ||
} | ||
|
||
alias gradle=gradle-or-gradlew |