I'm trying to learn Gradle. My preferred style of learning is to understand at a low level what is going on. To that end, I am trying to interpret what's happening in example 6.1 of the documentation with respect to the DSL reference:
task hello { doLast { println 'Hello world!' } }
I understand that this script is executed in the context of a Project
. So I can see from the Project
documentation that there are a number of overloaded task(...)
methods. Looking at the signatures, I need to chose one which has a closure as the final argument. And since we're not passing a Map
here, I assume the method that's being called is task(String name, Closure closure)
.
However, the part I'm struggling with is how, in this script, the literal string hello
gets mapped to a String
.
Another example is example 6.7:
task taskX(dependsOn: 'taskY') << { println 'taskX' } task taskY << { println 'taskY' }
Here, I assume we're calling the task(Map<String, ?> args, String name)
form of the method. But,
taskX
end up as a String
?Map
literal, how does the part in parentheses end up being a Map
?Project
object to resolve taskX
as an unknown method. But, AFAIK, a method call wouldn't be syntactically valid at this point given the method call to task
immediately preceding it.As you can see I'm a bit confused as to how the example syntax maps down to the DSL reference guide, which is making it a bit tricky for me to really understand what's happening at a grass-roots level.
Thanks!
Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.
The dependency tree in a build scan renders the selection reason (conflict resolution) as well as the origin of a dependency if you click on a dependency and select the "Required By" tab. Every Gradle project provides the task dependencyInsight to render the so-called dependency insight report from the command line.
Kotlin DSL is fully supported in Intellij IDEA and Android Studio. Other IDEs, such as Eclipse or NetBeans, do not yet provide helpful tools for editing Gradle Kotlin DSL files, however, importing and working with Kotlin DSL-based builds work as usual.
It means that dependency graph contains multiple dependencies with the same group and module but different versions for e.g. org.
The task foo
variation of the task declaration syntax is special in that it's implemented using a Groovy compiler plugin. As far as I know, this is the only case where a compiler plugin is used to support a special syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With