_gradle 25 KB

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