Why can't see all task when use 'tasks'

2019-05-26 01:53发布

问题:

task startSession << {
chant()
}
def chant() {
ant.echo(message: 'Repeat after me...')
}
3.times {
task "yayGradle$it" << {
println 'Gradle rocks'
}
}
yayGradle0.dependsOn startSession
yayGradle2.dependsOn yayGradle1, yayGradle0
task groupTherapy(dependsOn: yayGradle2)

In my script I have startSession task, groupTherapy task and three dynamically generated tasks yayGradle0-3. When I am executing:

gradle tasks 

Part of the output is:

Other tasks
-----------
groupTherapy

Where are the other tasks? If I execute the command above with parameter --all they are visible but not as indipendant tasks but like dependent on groupTherapy. Why Gradle doesn't show task startSession as separate task for example?

回答1:

gradle tasks show tasks that no other task depends on, and tasks that have task.group set. The idea is that these are the tasks that are clearly meant to be executed directly, whereas the (often many) remaining tasks aren't. gradle tasks --all shows all tasks.