3.7.8 插件的JAR依赖 - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith
Version: null
3.7.8 插件的JAR依赖
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.To define a dependency that is resolved for use with the plugin but not exported to the application then you can set theexport property of the dependency:test('org.spockframework:spock-core:0.5-groovy-1.8') {
export = false
}test group: 'org.spockframework', name: 'spock-core',
version: '0.5-groovy-1.8', export: falseYou can useexported = falseinstead ofexport = false, but we recommend the latter because it's consistent with the Map argument.
指定插件的JAR依赖
为一个插件指定依赖的方式跟你为一个应用的方式一致。当一个插件被安装以后,此应用将自动继承插件的依赖。如果希望插件的依赖 不要导出 到应用中,可以通过设置export属性来完成:test('org.spockframework:spock-core:0.5-groovy-1.8') {
export = false
}test group: 'org.spockframework', name: 'spock-core',
version: '0.5-groovy-1.8', export: false你也可以使用exported = false来替代export = false,但是我们推荐你使用后者,因为这样可以跟Map参数保持一致。
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(":hibernate:$grailsVersion") {
excludes "javassist"
}
}dependencies {
runtime "javassist:javassist:3.4.GA"
}excludes method, effectively excluding the javassist library as a dependency.
在应用中覆盖插件依赖
如果一个插件使用到的JAR依赖跟另外一个插件或者应用的依赖相冲突,你可以使用排除加覆盖的方式来解决,比如:plugins {
compile(":hibernate:$grailsVersion") {
excludes "javassist"
}
}dependencies {
runtime "javassist:javassist:3.4.GA"
}excludes方法排除掉javassist框架,而后另外声明其依赖。

