问题
When I walk through the gradle dsl guide, I notice the DependencyHandler. It's delegated to closure when execute dependencies method. Just like
dependencies {
compile 'commons-lang:commons-lang:2.6'
}
The point I can't understand is why "compile 'commons-lang:commons-lang:2.6'" caused the method "add(configurationName, dependencyNotation)" be invoked.
回答1:
Internally Gradle uses Groovy's metaprogramming features, specifically methodMissing, to implement this capability. You can see how this is done in the DependencyHandler implementation.
来源:https://stackoverflow.com/questions/32131860/how-gradle-dependencies-work