0

this official doc describes how to define a task in gradle,E.g:

task helloTask {
   println 'Hello World!'
}

it seems this code actually means a method call, which is Task task(String name, Closure configureClosure).

Since this is a method call, helloTask shoule be parameter name, which is String type. So where is the ‘’ or ""

ps.

BTW, the parentheses looks different with standard groovy method call.

wuyi
  • 227
  • 1
  • 17
  • 1
    Groovy provides several syntactic features that can make calls look nicer. The above actually is a call of the mentioned method. – Henry Jan 20 '19 at 09:44
  • 2
    Possible duplicate of [How to interpret Gradle DSL](https://stackoverflow.com/questions/12326264/how-to-interpret-gradle-dsl) – M.Ricciuti Jan 20 '19 at 18:10
  • @M.Ricciuti thanks a lot – wuyi Jan 21 '19 at 01:30

1 Answers1

0

I think it should look something like this:

task mytask(group:'mygroup', description:"my own simple task") {

    println 'this will be executed on evaluate, so on _any_ task'

    doLast {
        println 'after all tasks are evaluated this will only executed if mytask is executed'
    }

}
Dirk Hoffmann
  • 1,444
  • 17
  • 35