Being new to both Gradle and Groovy I find myself having a hard time understanding the syntax of a build.gradle script.
I understand (at least I think so) that build.gradle is plain groovy code used as DSL where the keywords are defined elsewhere.
Please explain what the different parts are. Taken from the Tutorial:
defaultTasks 'distribution'
task distribution << {
println "We build the zip with version=$version"
}
task release(dependsOn: 'distribution') << {
println 'We release now'
}
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(release)) {
version = '1.0'
} else {
version = '1.0-SNAPSHOT'
}
}
e.g. I think I know println is a function. I know text in quotation marks is a string. I guess stuff in curly braces is a closure.
But what is release
/distribution
? Is it a string, too? Is it a parameter to a function task
? And why can I use it in hasTask(release)
without quotation marks?
So what exacly is: defaultTasks
, task
, release
, <<
, gradle
, whenReady
, ->
?
Bonus: is there a groovy way to find out myself?