Dependencies syntax

(Richard Schubert) #1


Using the method “void dependencies(Closure configureClosure)” I can configure the dependencies of my projects.
dependencies {
compile ‘org.codehaus.groovy:groovy-all:2.3.11’

In this case the “dependencies” function is passed a configuration closure whose delegate is an object of type “DependenciesHandler”.
What is don’t understand is how the line "compile ‘org.codehaus…’ can work. The DependencyHandler interface does not have a property called “compile”. Rather it seems that the function “Dependency add(String configurationName, Object dependencyNotation)” is called with “compile” and “org.codehaus…” as its two arguments.
However the function name “add” does not have to be written. Why?

(Lance Java) #2

It’s all down to groovy’s methodMissing() support.