Q:

how to add custom dependency handler in a gradle plugin?

I would like to provide users of my gradle plugin a simple way to add all necessary dependencies. something like gradleApi() or localGroovy(). 
I found out that both - gradleApi and localGroovy - are defined in DependencyHandler and implemented in DefaultDependencyHandler. Can i provide a custom implementation of Dependencyhandler which extends DefaultDependencyHandler in my plugin? Or is there even a simplier way to achieve what i want?
thx in advance.

A:

One solution is to have the plugin install an extra method on the dependencies container:
def jarDir = ...

project.dependencies.ext.pluginDeps = { 
    project.fileTree(jarDir) // filter file tree if necessary 
}

Users can then do:
dependencies {
    compile pluginDeps()
}

Extra properties/methods are normally meant to be used by build scripts only (because they aren't backed by a model that can be discovered and reasoned about), but in this particular case (and as of Gradle 2.1) I can't think of a clearly better solution.
PS: Keep in mind that for file (rather than repository) based dependencies, no version conflict resolution will occur.

