_gradle 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. #compdef gradle gradlew gw
  2. __gradle-set-project-root-dir() {
  3. local dir=`pwd`
  4. project_root_dir=`pwd`
  5. while [[ $dir != '/' ]]; do
  6. if [[ -f "$dir/settings.gradle" || -f "$dir/settings.gradle.kts" || -f "$dir/gradlew" ]]; then
  7. project_root_dir=$dir
  8. return 0
  9. fi
  10. dir="$(dirname "$dir")"
  11. done
  12. return 1
  13. }
  14. __gradle-init-cache-dir() {
  15. cache_dir="${GRADLE_USER_HOME:-$HOME/.gradle}/completion"
  16. mkdir -p $cache_dir
  17. }
  18. __gradle-set-settings-file() {
  19. # In order of precedence: --settings-file=filename, settings.gradle, settings.gradle.kts
  20. local default_gradle_settings_file="$project_root_dir/settings.gradle"
  21. if [[ ! -f $default_gradle_settings_file ]]; then
  22. default_gradle_settings_file="$project_root_dir/settings.gradle.kts"
  23. fi
  24. gradle_settings_file=${${(v)opt_args[(i)-c|--settings-file]}:-$default_gradle_settings_file}
  25. }
  26. __gradle-set-build-file() {
  27. __gradle-set-settings-file
  28. # In order of precedence: --build-file=filename, rootProject.buildFileName, build.gradle, build.gradle.kts
  29. local default_gradle_build_file_name="build.gradle"
  30. if [[ -r $gradle_settings_file ]]; then
  31. default_gradle_build_file_name=${$(grep "^rootProject\.buildFileName" $gradle_settings_file | \
  32. sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p")}
  33. default_gradle_build_file_name="${default_gradle_build_file:-build.gradle}"
  34. fi
  35. local default_gradle_build_file="$project_root_dir/$default_gradle_build_file_name"
  36. if [[ ! -f $default_gradle_build_file ]]; then
  37. default_gradle_build_file="$project_root_dir/build.gradle.kts"
  38. fi
  39. # If a build file is specified after '-b' or '--build-file', use this file.
  40. gradle_build_file=${${(v)opt_args[(i)-b|--build-file]}:-$default_gradle_build_file}
  41. }
  42. __gradle-set-cache-name() {
  43. # Cache name is constructed from the absolute path of the build file.
  44. cache_name=${${gradle_build_file:a}//[^[:alnum:]]/_}
  45. }
  46. __gradle-set-files-checksum() {
  47. # Cache MD5 sum of all Gradle scripts and modified timestamps
  48. if builtin command -v md5 > /dev/null; then
  49. gradle_files_checksum=( $(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null)") )
  50. elif builtin command -v md5sum > /dev/null; then
  51. gradle_files_checksum=( $(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}') )
  52. else
  53. _message 'Cannot generate completions as neither md5 nor md5sum exist on \$PATH'
  54. return 1
  55. fi
  56. }
  57. __gradle-generate-script-cache() {
  58. # Invalidate cache after 3 weeks by default
  59. local cache_ttl_mins=${$(echo $GRADLE_CACHE_TTL_MINUTES):-30240}
  60. local script_exclude_pattern=${$(echo $GRADLE_COMPLETION_EXCLUDE_PATTERN):-"/(.git|build|integTest|samples|templates|smokeTest|testFixtures|out)/"}
  61. if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2>/dev/null) ]]; then
  62. zle -R "Generating Gradle build script cache"
  63. # Cache all Gradle scripts
  64. local -a gradle_build_scripts
  65. gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern") )
  66. printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name
  67. fi
  68. }
  69. __gradle-generate-tasks-cache() {
  70. __gradle-set-files-checksum
  71. # Use Gradle wrapper when it exists.
  72. local gradle_cmd="gradle"
  73. if [[ -x "$project_root_dir/gradlew" ]]; then
  74. gradle_cmd="$project_root_dir/gradlew"
  75. fi
  76. zle -R "Generating Gradle task cache from $gradle_build_file"
  77. # Run gradle to retrieve possible tasks and cache.
  78. # Reuse Gradle Daemon if IDLE but don't start a new one.
  79. local gradle_tasks_output
  80. if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then
  81. gradle_tasks_output="$($gradle_cmd --daemon --no-scan --build-file $gradle_build_file --console=plain -q tasks --all 2>/dev/null)"
  82. else
  83. gradle_tasks_output="$($gradle_cmd --no-daemon --no-scan --build-file $gradle_build_file --console=plain -q tasks --all 2>/dev/null)"
  84. fi
  85. local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
  86. local -a match
  87. for output_line in ${(f)"$(printf "%s\n" "${gradle_tasks_output[@]}")"}; do
  88. if [[ $output_line =~ ^([[:alpha:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
  89. local task_name="${match[1]}"
  90. local task_description="${match[3]}"
  91. # Completion for subproject tasks with ':' prefix
  92. if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]]; then
  93. gradle_all_tasks+="${task_name//:/\\:}:$task_description\n\\:${task_name//:/\\:}:$task_description\n"
  94. subproject_tasks+="${match[2]}\n"
  95. else
  96. gradle_all_tasks+="${task_name//:/\\:}:$task_description\n"
  97. root_tasks+="$task_name\n"
  98. fi
  99. fi
  100. done
  101. # subproject tasks can be referenced implicitly from root project
  102. if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then
  103. local -a implicit_tasks
  104. implicit_tasks=( $(comm -23 <(echo $subproject_tasks | sort) <(echo $root_tasks | sort)) )
  105. for task in $(printf "%s\n" "${implicit_tasks[@]}"); do
  106. gradle_all_tasks+="$task\n"
  107. done
  108. fi
  109. echo $gradle_all_tasks >| $cache_dir/$gradle_files_checksum
  110. echo $gradle_files_checksum >| $cache_dir/$cache_name.md5
  111. }
  112. __gradle-completion-init() {
  113. local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
  114. __gradle-init-cache-dir
  115. __gradle-set-project-root-dir
  116. __gradle-set-build-file
  117. if [[ -f $gradle_build_file ]]; then
  118. __gradle-set-cache-name
  119. __gradle-generate-script-cache
  120. __gradle-set-files-checksum
  121. __gradle-generate-tasks-cache
  122. fi
  123. return 0
  124. }
  125. __gradle_tasks() {
  126. local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
  127. __gradle-init-cache-dir
  128. __gradle-set-project-root-dir
  129. __gradle-set-build-file
  130. if [[ -f $gradle_build_file ]]; then
  131. __gradle-set-cache-name
  132. __gradle-generate-script-cache
  133. __gradle-set-files-checksum
  134. # The cache key is md5 sum of all gradle scripts, so it's valid if it exists.
  135. if [[ -f $cache_dir/$cache_name.md5 ]]; then
  136. local cached_checksum="$(cat $cache_dir/$cache_name.md5)"
  137. local -a cached_tasks
  138. if [[ -z $cur ]]; then
  139. cached_tasks=(${(f)"$(grep -v "^\\\:" $cache_dir/$cached_checksum)"})
  140. else
  141. cached_tasks=(${(f)"$(grep "^${cur//:/\\\\:}" $cache_dir/$cached_checksum)"})
  142. fi
  143. _describe 'all tasks' cached_tasks && ret=0
  144. else
  145. __gradle-generate-tasks-cache
  146. fi
  147. # Regenerate tasks cache in the background
  148. if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum || $(wc -c < $cache_dir/$gradle_files_checksum) -le 1 ]]; then
  149. $(__gradle-generate-tasks-cache &> /dev/null &)
  150. fi
  151. else
  152. _describe 'built-in tasks' '(
  153. "buildEnvironment:Displays all buildscript dependencies declared in root project."
  154. "components:Displays the components produced by root project."
  155. "dependencies:Displays all dependencies declared in root project."
  156. "dependencyInsight:Displays the insight into a specific dependency in root project."
  157. "dependentComponents:Displays the dependent components of components in root project."
  158. "help:Displays a help message."
  159. "init:Initializes a new Gradle build."
  160. "model:Displays the configuration model of root project."
  161. "projects:Displays the sub-projects of root project."
  162. "properties:Displays the properties of root project."
  163. "tasks:Displays the tasks runnable from root project."
  164. "wrapper:Generates Gradle wrapper files."
  165. )' && ret=0
  166. fi
  167. }
  168. __gradle_subcommand() {
  169. integer ret=1
  170. case "$words[1]" in
  171. (dependencies)
  172. _arguments \
  173. '--configuration=[The configuration to generate the report for.]:dependency configuration:_gradle_dependency_configurations' && ret=0
  174. ;;
  175. (dependencyInsight)
  176. _arguments \
  177. '--dependency=[Shows the details of given dependency.]' \
  178. '--configuration=[Looks for the dependency in given configuration.]:dependency configuration:_gradle_dependency_configurations' && ret=0
  179. ;;
  180. (help)
  181. _arguments \
  182. '--task[The task to show help for.]' && ret=0
  183. ;;
  184. (init)
  185. _arguments \
  186. '--dsl=[DSL to be used in generated scripts.]:dsl:(groovy kotlin)' \
  187. '--package=[Package for the generated source.]' \
  188. '--project-name=[Name of the generated project.]' \
  189. '--test-framework=[Test framework to be used.]:test framework:(junit kotlintest scalatest spock testng)' \
  190. '--type=[Project type to generate.]:project type:(basic cpp-application cpp-library groovy-application groovy-library java-application java-library kotlin-application kotlin-library pom scala-library)' && ret=0
  191. ;;
  192. (tasks)
  193. _arguments \
  194. '--all[List all tasks, including subproject tasks.]' \
  195. '--group=[Show tasks only from given task group.]' && ret=0
  196. ;;
  197. (test)
  198. _arguments -C \
  199. '--debug-jvm[Enable debugging for the test process. The process is started suspended and listening on port 5005. Requires the "java" plugin.]' \
  200. '--fail-fast[Stops test execution after the first failed test. Requires the "java" plugin.]' \
  201. '--tests=[Sets test class or method name to be included, * is supported. Requires the "java" plugin.]' \
  202. '(-)*:: :->task-or-option' && ret=0
  203. ;;
  204. (wrapper)
  205. _arguments \
  206. '--distribution-type=[Binary-only or all with docs and sources]:*:distribution type:(bin all)' \
  207. '--gradle-version=[Set Gradle version for wrapper]' \
  208. '--gradle-distribution-sha256-sum=[SHA-256 checksum]' \
  209. '--gradle-distribution-url=[Set Gradle distribution URL]' && ret=0
  210. ;;
  211. (*)
  212. _arguments -C \
  213. {-a,--no-rebuild}'[Do not rebuild project dependencies.]' \
  214. '(--no-build-cache)--build-cache[Enable the Gradle build cache.]' \
  215. {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \
  216. {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \
  217. {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle' \
  218. '(--configuration-cache)--no-configuration-cache[Disables the configuration cache. Gradle will not reuse the build configuration from previous builds.]' \
  219. '--configuration-cache-problems=[Configures how the configuration cache handles problems]:problem handling:(fail warn)' \
  220. '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \
  221. '(--no-configuration-cache)--configuration-cache[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
  222. '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \
  223. '--continue[Continues task execution after a task failure.]' \
  224. '-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \
  225. '-Dorg.gradle.caching=[Set true to enable Gradle build cache.]:enable build cache:(true false)' \
  226. '-Dorg.gradle.console=[Set type of console output to generate.]:console output type:(plain auto rich verbose)' \
  227. '-Dorg.gradle.daemon.debug=[Set true to debug Gradle Daemon.]:enable daemon debug:(true false)' \
  228. '-Dorg.gradle.daemon.idletimeout=[Kill Gradle Daemon after # idle millis.]' \
  229. '-Dorg.gradle.debug=[Set true to debug Gradle Client.]' \
  230. '-Dorg.gradle.jvmargs=[Set JVM arguments.]' \
  231. '-Dorg.gradle.java.home=[Set JDK home dir.]' \
  232. '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \
  233. '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:enable parallel build:(true false)' \
  234. '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
  235. '-Dorg.gradle.unsafe.watch-fs=[Set true to enable Gradle file watcher.]:enable watcher:(true false)' \
  236. '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \
  237. '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \
  238. '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \
  239. '(--no-daemon)--daemon[Uses the Gradle daemon to run the build. Starts the daemon if not running.]' \
  240. '--foreground[Starts the Gradle daemon in the foreground.]' \
  241. {-g,--gradle-user-home}'[Specifies the gradle user home directory.]:file:_directories' \
  242. \*--include-build'[Includes the specified build in the composite.]:file:_directories' \
  243. \*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle' \
  244. '(-d --debug -w --warn -q --quiet)'{-i,--info}'[Set log level to info.]' \
  245. '--max-workers[Set the maximum number of concurrent workers that Gradle may use.]:number workers' \
  246. {-m,--dry-run}'[Runs the builds with all task actions disabled.]' \
  247. '--no-color[Do not use color in the console output. (Removed in Gradle 3.0)]' \
  248. '(--build-cache)--no-build-cache[Do not use the Gradle build cache.]' \
  249. '(--configure-on-demand)--no-configure-on-demand[Disables configuration on demand.]' \
  250. '(--daemon)--no-daemon[Do not use the Gradle daemon to run the build.]' \
  251. '(--parallel)--no-parallel[Disables parallel execution to build projects.]' \
  252. '(--scan)--no-scan[Do not create a build scan.]' \
  253. '--offline[The build should operate without accessing network resources.]' \
  254. \*{-P+,--project-prop}'[Set project property for the build script (e.g. -Pmyprop=myvalue).]:project property (prop=val):' \
  255. {-p,--project-dir}'[Specifies the start directory for Gradle.]:start directory:_directories' \
  256. '(--no-parallel)--parallel[Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]' \
  257. '--profile[Profiles build execution time and generates a report in the <build_dir>/reports/profile directory.]' \
  258. '--priority[Set priority for Gradle worker processes.]:priority:(low normal)' \
  259. '--project-cache-dir[Specifies the project-specific cache directory.]:cache directory:_directories' \
  260. '(-d --debug -w --warn -i --info)'{-q,--quiet}'[Log errors only.]' \
  261. '--recompile-scripts[Force build script recompiling.]' \
  262. '--refresh[Refresh the state of resources of the type(s) specified.]:refresh policy:(dependencies)' \
  263. '--refresh-dependencies[Refresh the state of dependencies.]' \
  264. '--rerun-tasks[Ignore previously cached task results.]' \
  265. '(--no-scan)--scan[Create a build scan.]' \
  266. '(-S --full-stacktrace)'{-s,--stacktrace}'[Print out the stacktrace for all exceptions.]' \
  267. '(-s --stacktrace)'{-S,--full-stacktrace}'[Print out the full (very verbose) stacktrace for all exceptions.]' \
  268. '--system-prop[system property (prop=val)]' \
  269. {-t,--continuous}'[Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.]' \
  270. {-u,--no-search-upward}"[Don't search in parent folders for a settings.gradle file.]" \
  271. '(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \
  272. '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \
  273. '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \
  274. '(--no-watch-fs)--watch-fs[Gradle watches filesystem for incremental builds.]' \
  275. '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \
  276. {-x,--exclude-task}'[Specify a task to be excluded from execution.]' && ret=0
  277. ;;
  278. esac
  279. return ret
  280. }
  281. (( $+functions[_gradle_dependency_configurations] )) ||
  282. _gradle_dependency_configurations() {
  283. local configurations
  284. configurations=(
  285. 'compileClasspath'
  286. 'runtimeClasspath'
  287. 'testCompileClasspath'
  288. 'testRuntimeClasspath'
  289. )
  290. _describe -t 'dependency configurations' "dependency configuration" configurations
  291. }
  292. _gradle() {
  293. local cur=${words[CURRENT]}
  294. local curcontext="$curcontext" state
  295. integer ret=1
  296. typeset -A opt_args
  297. _arguments -C \
  298. '(-)'{-\?,-h,--help}'[Shows a help message.]' \
  299. {-a,--no-rebuild}'[Do not rebuild project dependencies.]' \
  300. '(--no-build-cache)--build-cache[Enable the Gradle build cache.]' \
  301. {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \
  302. {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \
  303. {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle:->argument-expected' \
  304. '(--no-configuration-cache)--configuration-cache[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
  305. '(--configuration-cache)--no-configuration-cache[Disables the configuration cache. Gradle will not reuse the build configuration from previous builds.]' \
  306. '--configuration-cache-problems=[Configures how the configuration cache handles problems]:problem handling:(fail warn)' \
  307. '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \
  308. '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \
  309. '--continue[Continues task execution after a task failure.]' \
  310. '-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \
  311. '-Dorg.gradle.caching=[Set true to enable Gradle build cache.]' \
  312. '-Dorg.gradle.console=[Set type of console output to generate.]:console output type:(plain auto rich verbose)' \
  313. '-Dorg.gradle.daemon.debug=[Set true to debug Gradle Daemon.]' \
  314. '-Dorg.gradle.daemon.idletimeout=[Kill Gradle Daemon after # idle millis.]' \
  315. '-Dorg.gradle.debug=[Set true to debug Gradle Client.]' \
  316. '-Dorg.gradle.jvmargs=[Set JVM arguments.]' \
  317. '-Dorg.gradle.java.home=[Set JDK home dir.]' \
  318. '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \
  319. '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:(true false)' \
  320. '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
  321. '-Dorg.gradle.unsafe.watch-fs=[Set true to enable Gradle file watcher.]:enable watcher:(true false)' \
  322. '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \
  323. '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \
  324. '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \
  325. '(--no-daemon)--daemon[Uses the Gradle daemon to run the build. Starts the daemon if not running.]' \
  326. '--foreground[Starts the Gradle daemon in the foreground.]' \
  327. {-g,--gradle-user-home}'[Specifies the gradle user home directory.]:home directory:_directories:->argument-expected' \
  328. '(-)--gui[Launches the Gradle GUI. (Removed in Gradle 4.0)]' \
  329. \*--include-build'[Includes the specified build in the composite.]:file:_directories:->argument-expected' \
  330. \*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle:->argument-expected' \
  331. '(-d --debug -w --warn -q --quiet)'{-i,--info}'[Set log level to info.]' \
  332. '--max-workers[Set the maximum number of concurrent workers that Gradle may use.]:number workers:->argument-expected' \
  333. {-m,--dry-run}'[Runs the builds with all task actions disabled.]' \
  334. '--no-color[Do not use color in the console output. (Removed in Gradle 3.0)]' \
  335. '(--build-cache)--no-build-cache[Do not use the Gradle build cache.]' \
  336. '(--configure-on-demand)--no-configure-on-demand[Disables configuration on demand.]' \
  337. '(--daemon)--no-daemon[Do not use the Gradle daemon to run the build.]' \
  338. '(--parallel)--no-parallel[Disables parallel execution to build projects.]' \
  339. '(--scan)--no-scan[Do not create a build scan.]' \
  340. '--offline[The build should operate without accessing network resources.]' \
  341. \*{-P+,--project-prop}'[Set project property for the build script (e.g. -Pmyprop=myvalue).]:project property (prop=val):->argument-expected' \
  342. {-p,--project-dir}'[Specifies the start directory for Gradle.]:start directory:_directories:->argument-expected' \
  343. '(--no-parallel)--parallel[Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]' \
  344. '--priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
  345. '--profile[Profiles build execution time and generates a report in the <build_dir>/reports/profile directory.]' \
  346. '--project-cache-dir=[Specifies the project-specific cache directory.]:cache directory:_directories:->argument-expected' \
  347. '(-d --debug -w --warn -i --info)'{-q,--quiet}'[Log errors only.]' \
  348. '--recompile-scripts[Force build script recompiling.]' \
  349. '--refresh[Refresh the state of resources of the type(s) specified.]:refresh policy:(dependencies)' \
  350. '--refresh-dependencies[Refresh the state of dependencies.]' \
  351. '--rerun-tasks[Ignore previously cached task results.]' \
  352. '(--no-scan)--scan[Create a build scan.]' \
  353. '(-S --full-stacktrace)'{-s,--stacktrace}'[Print out the stacktrace for all exceptions.]' \
  354. '(-s --stacktrace)'{-S,--full-stacktrace}'[Print out the full (very verbose) stacktrace for all exceptions.]' \
  355. '(-)--status[Shows status of running and recently stopped Gradle Daemons.]' \
  356. '(-)--stop[Stops all Gradle daemons.]' \
  357. '--system-prop[system property (prop=val)]' \
  358. {-t,--continuous}'[Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.]' \
  359. {-u,--no-search-upward}"[Don't search in parent folders for a settings.gradle file.]" \
  360. '(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \
  361. '(-)'{-v,--version}'[Print version info.]' \
  362. '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \
  363. '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \
  364. '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \
  365. '(--no-watch-fs)--watch-fs[Gradle watches filesystem for incremental builds.]' \
  366. {-x,--exclude-task}'[Specify a task to be excluded from execution.]' \
  367. '(-)*:: :->task-or-option' && ret=0
  368. if [[ $words[CURRENT] != -* && $state != "argument-expected" ]]; then
  369. __gradle_tasks && ret=0
  370. else
  371. curcontext=${curcontext%:*:*}:gradle-$words[1]:
  372. __gradle_subcommand && ret=0
  373. fi
  374. return ret
  375. }
  376. _gradle "$@"