_gradle 24 KB

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