I'm having a hard time understanding how Gradle's Groovy DSL works.
Unfortunately Gradle is the main use-case for Groovy that I come across in my day to day work, and I've noticed that for many devs, their exposure to Groovy is strictly through Gradle. And that a majority of Gradle users have a very limited grasp of Groovy as a consequence.
In my limited understanding of Groovy, the following sintax tokenA tokenB { tokenC }
where all tokens are not language keywords, tokenA
would be a method that we are calling with arguments tokenB
and the final argument is a closure. I would like to think I'm correct, but I know I'm wrong because there probably needs to be a comma after tokenB for that analysis to be correct.
I am by no means, as you can already tell, a Groovy dev, and I think using Gradle without learning the basics of Groovy is a bad thing to do, because it limits me from fully exploiting its capabilities. But my only viable option is to learn though examples without learning the theory unfortunately.
I did check out some similar questions like this one but no answers where clear or complete enough for me.
TL;DR
- How are the tokens
task myTask { doLast {} }
interpreted in Groovy? - Does Gradle use a standard Groovy interpreter?
- How is
myTask
interpreted as an identifier when there istask
and notdef
or a type behind it? - If later in the file I added
myTask { dependsOn myOtherTask }
how does that get interpreted?