-
-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Added Gradle plugin #625
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
``` |
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That code seems to be licensed under the MIT license, meaning that the original copyright notice should be retained. Please include it. |
||||||
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
echo "executing gradlew instead of gradle" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case the user pipes the commands, I think this type of informative message should go to stderr. What do you think?
Suggested change
|
||||||
"$project_root/gradlew" "$@" | ||||||
else | ||||||
command gradle "$@" | ||||||
fi | ||||||
} | ||||||
|
||||||
alias gradle=gradle-or-gradlew |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin doesn't seem to provide completions. Is there a plan to add them?