zoukankan      html  css  js  c++  java
  • Gradle Goodness: Display Available Tasks

    To see which tasks are available for our build we can run Gradle with the command-line option -t or --tasks. Gradle outputs the available tasks from our build script. By default only the tasks which are dependencies on other tasks are shown. To see all tasks we must add the command-line option --all.

    00.3.times { counter ->
    01.task "lib$counter" {
    02.description = "Build lib$counter"
    03.if (counter > 0) {
    04.dependsOn = ["lib${counter - 1}"]
    05.}
    06.}
    07.}
    08. 
    09.task compile {
    10.dependsOn {
    11.project.tasks.findAll {
    12.it.name.startsWith('lib')
    13.}
    14.}
    15.description = "Compile sources"
    16.}
    $ gradle -q -t
     
    ------------------------------------------------------------
    Root Project
    ------------------------------------------------------------
     
    Tasks
    -----
    :compile - Compile sources
    $ gradle -q --tasks -all
     
    ------------------------------------------------------------
    Root Project
    ------------------------------------------------------------
     
    Tasks
    -----
    :compile - Compile sources
    :lib0 - Build lib0
    :lib1 - Build lib1
    :lib2 - Build lib2

    But if we add our tasks to a group, we get even more verbose output. Gradle will group the tasks together and without the --all option we get to see all tasks belonging to the group, even those that are dependency tasks. And with the --all option we see for each task on which tasks it depends on. So by setting the group property on the task we get much better output when we ask Gradle about the available tasks.

    00.3.times { counter ->
    01.task "lib$counter" {
    02.description = "Build lib$counter"
    03.if (counter > 0) {
    04.dependsOn = ["lib${counter - 1}"]
    05.}
    06.}
    07.}
    08. 
    09.task compile {
    10.dependsOn {
    11.project.tasks.findAll {
    12.it.name.startsWith('lib')
    13.}
    14.}
    15.description = "Compile sources"
    16.}
    17. 
    18.tasks*.group = 'Compile'
    $ gradle -q -t
     
    ------------------------------------------------------------
    Root Project
    ------------------------------------------------------------
     
    Compile tasks
    -------------
    :compile - Compile sources
    :lib0 - Build lib0
    :lib1 - Build lib1
    :lib2 - Build lib2
    $ gradle -q --tasks -all
     
    ------------------------------------------------------------
    Root Project
    ------------------------------------------------------------
     
    Compile tasks
    -------------
    :compile - Compile sources [:lib0, :lib1, :lib2]
    :lib0 - Build lib0
    :lib1 - Build lib1 [:lib0]
    :lib2 - Build lib2 [:lib1]
  • 相关阅读:
    MDK+VS+Eclipse的STM32库V3.5工程模板的建立(六)
    MDK+VS+Eclipse的STM32库V3.5工程模板的建立(一)
    MDK+VS+Eclipse的STM32库V3.5工程模板的建立(四)
    ognl.OgnlException: target is null for setProperty(null, "username", [Ljava.lang.String;@19af9e98)
    Hibernate联合主键Annotation
    struts2入门第一天配置环境
    为什么java的构造方法中this()或者super()要放在第一行
    几种解决IE6下PNG图片透明问题
    IE6解决min_height
    一个拖拽例子
  • 原文地址:https://www.cnblogs.com/GoAhead/p/4189111.html
Copyright © 2011-2022 走看看