Specifying Plugin JAR dependencies

The way in which you specify dependencies for a plugin is identical to how you specify dependencies in an application. When a plugin is installed into an application the application automatically inherits the dependencies of the plugin.

If you want to define a dependency that is resolved for use with the plugin but not exported to the application then you can set the exported property of the dependency:

compile('org.hibernate:hibernate-core:3.3.1.GA') {
    exported = false
}

In this can the hibernate-core dependency will be available only to the plugin and not resolved as an application dependency.

Overriding Plugin JAR Dependencies in Your Application

If a plugin is using a JAR which conflicts with another plugin, or an application dependency then you can override how a plugin resolves its dependencies inside an application using exclusions. For example:

plugins {
    compile("org.codehaus.griffon.plugins:miglayout:0.3" ) {
        excludes "miglayout"
    }
}

dependencies { String miglayoutVersion = '4.2' compile "com.miglayout:miglayout-core:$miglayoutVersion", "com.miglayout:miglayout-swing:$miglayoutVersion" }

In this case the application explicitly declares a dependency on the "miglayout" plugin and specifies an exclusion using the excludes method, effectively excluding the miglayout library as a dependency.