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 the plugin method:

plugin("hibernate") {
    compile( 'org.hibernate:hibernate-core:3.3.1.GA') {
		excludes 'ehcache', 'xml-apis', 'commons-logging'
	}
    compile 'org.hibernate:hibernate-annotations:3.4.0.GA',
			'org.hibernate:hibernate-commons-annotations:3.3.0.ga'

runtime 'javassist:javassist:3.4.GA' }

In this case the application is controlling how the hibernate plugin resolves dependencies and not the hibernate plugin. If you wish to simply exclude a single dependency resolved by a plugin then you can do so:

plugin("hibernate") {
    runtime "cglib:cglib-nodep:2.1_3"
	excludes 'javassist:javassist:3.4.GA'	
}