c2a95b796b79b4ce4e36b8cb879cb9b0162bc438
- Author
- Matthew Git McCullough <matthewm@ambientideas.com>
- Committer
- Matthew McCullough <matthewm@ambientideas.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..fc4c78c503c26ef2762cb1f84df3476670b1a84d
4--- /dev/null
5+++ b/plugins/gradle/gradle.plugin.zsh
6@@ -0,0 +1,119 @@
7+#!zsh
8+##############################################################################
9+# A descriptive listing of core Gradle commands
10+############################################################################
11+function _gradle_core_commands() {
12+ local ret=1 state
13+ _arguments ':subcommand:->subcommand' && ret=0
14+
15+ case $state in
16+ subcommand)
17+ subcommands=(
18+ "properties:Display all project properties"
19+ "tasks:Calculate and display all tasks"
20+ "dependencies:Calculate and display all dependencies"
21+ "projects:Discover and display all sub-projects"
22+ "build:Build the project"
23+ "help:Display help"
24+ )
25+ _describe -t subcommands 'gradle subcommands' subcommands && ret=0
26+ esac
27+
28+ return ret
29+}
30+
31+function _gradle_arguments() {
32+ _arguments -C \
33+ '-a[Do not rebuild project dependencies]' \
34+ '-h[Help]' \
35+ '-D[System property]' \
36+ '-d[Log at the debug level]' \
37+ '--gui[Launches the Gradle GUI app]' \
38+ '--stop[Stop the Gradle daemon]' \
39+ '--daemon[Use the Gradle daemon]' \
40+ '--no-daemon[Do not use the Gradle daemon]' \
41+ '--no-opt[Do not perform any task optimization]' \
42+ '-i[Log at the info level]' \
43+ '-m[Dry run]' \
44+ '-P[Set a project property]' \
45+ '--profile[Profile the build time]' \
46+ '-q[Log at the quiet level (only show errors)]' \
47+ '-v[Print the Gradle version info]' \
48+ '-x[Specify a task to be excluded]' \
49+ '*::command:->command' \
50+ && return 0
51+}
52+
53+
54+##############################################################################
55+# Are we in a directory containing a build.gradle file?
56+############################################################################
57+function in_gradle() {
58+ if [[ -f build.gradle ]]; then
59+ echo 1
60+ fi
61+}
62+
63+############################################################################
64+# Define the stat_cmd command based on platform behavior
65+##########################################################################
66+stat -f%m . > /dev/null 2>&1
67+if [ "$?" = 0 ]; then
68+ stat_cmd=(stat -f%m)
69+else
70+ stat_cmd=(stat -L --format=%Y)
71+fi
72+
73+############################################################################## Examine the build.gradle file to see if its
74+# timestamp has changed, and if so, regen
75+# the .gradle_tasks cache file
76+############################################################################
77+_gradle_does_task_list_need_generating () {
78+ if [ ! -f .gradletasknamecache ]; then return 0;
79+ else
80+ accurate=$($stat_cmd .gradletasknamecache)
81+ changed=$($stat_cmd build.gradle)
82+ return $(expr $accurate '>=' $changed)
83+ fi
84+}
85+
86+
87+##############################################################################
88+# Discover the gradle tasks by running "gradle tasks --all"
89+############################################################################
90+_gradle_tasks () {
91+ if [ in_gradle ]; then
92+ _gradle_arguments
93+ if _gradle_does_task_list_need_generating; then
94+ gradle tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
95+ fi
96+ compadd -X "==== Gradle Tasks ====" `cat .gradletasknamecache`
97+ fi
98+}
99+
100+_gradlew_tasks () {
101+ if [ in_gradle ]; then
102+ _gradle_arguments
103+ if _gradle_does_task_list_need_generating; then
104+ gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
105+ fi