The first thing to know is that Gradle uses AST for the dependecies
closure syntax this answer here does a good job of explaining what AST is.
I'll talk about the above code snippet, you are right about the block of code being delegated to the DependencyHandler
, the line
is defined here as
To declare a specific dependency for a configuration you can use the following syntax:
dependencies {
configurationName dependencyNotation1, dependencyNotation2, ...
}
The important thing to note here is the above code is syntax provided by Gradle to make code clean and terse. You could as well use the method DependencyHandler.add(String,Object)
For example
dependencies {
add('compile', fileTree(dir: "libs", include: "*.jar"))
}
As compared to the above syntax, the top syntax allows you to add multiple dependencies in a single statement and is a lot more cleaner.
fileTree()
, files()
etc are methods defined in Project
. From DependencyHandler.add(String,Object)
, the second argument is of type Object
, as such the method as well as the dependency syntax can accept a number of type of dependencies like ProjectDependency
, other Configuration
s and FileCollection
and its sub types as you mentioned the ConfigurableFileCollection
.