See the example in default_task
directory.
build.gradle :
defaultTasks 'clean', 'run'
task clean << {
println 'Default Cleaning!'
}
task run << {
println 'Default Running!'
}
task other << {
println "I'm not a default task!"
}
Run command gradle -q
and get the result:
Default Cleaning!
Default Running!
We can find:
defaultTasks
.We practice to find defaultTasks
in documentation and we find
it's Project.defaultTasks.
void defaultTasks(String... defaultTasks)
Sets the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
Parameters: defaultTasks - The default task names.
We can also find that the argument defaultTasks
is String ...
,
and we use the method in below way.
defaultTasks 'clean', 'run'
That's how we use array in groovy.