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
export
property of the dependency:
compile( 'org.hibernate:hibernate-core:3.3.1.GA') {
export = false
}
In this case the
hibernate-core
dependency will be available only to the plugin and not resolved as an application dependency. Alternatively, if you're using the map syntax:
compile( group: 'org.hibernate', name: 'hibernate-core', version: '3.3.1.GA', export: false )
You can use exported = false
instead of export = false
, but we recommend the latter because it's consistent with the map argument.
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 {
runtime( "org.grails.plugins:hibernate:1.3.0" ) {
excludes "javassist"
}
}dependencies {
runtime "javassist:javassist:3.4.GA"
}
In this case the application explicitly declares a dependency on the "hibernate" plugin and specifies an exclusion using the
excludes
method, effectively excluding the javassist library as a dependency.