【发布时间】:2015-03-12 03:21:20
【问题描述】:
我有一个 jar,build-plugins.jar,其中有一个 gradle 插件,它是在 build.gradle 中构建的:
apply plugin 'java'
dependencies {
compile gradleApi()
compile localGroovy()
compile('eviware:maven-soapui-plugin:4.5.1')
compile('org.antlr:stringtemplate:4.0.2')
compile('commons-io:commons-io:2.4')
compile('joda-time:joda-time:2.1')
}
这会构建 build-plugins.jar。而使用插件的项目按文件引用插件jar
apply plugin 'thepluginwahoo'
buildscript {
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.1'
classpath files('/path/to/build-plugins.jar')
}
}
问题是当我运行第二个项目的任何任务时,我得到“无法为类 xyz 创建类代理”,根本原因是四个依赖项(joda-time、commons-io、stringtemplate、maven -soapui-plugin) 不存在。如果我将依赖项添加到使用插件的项目中,那么它就可以正常工作:
apply plugin 'thepluginwahoo'
buildscript {
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.1'
classpath files('/path/to/build-plugins.jar')
classpath 'eviware:maven-soapui-plugin:4.5.1'
classpath 'org.antlr:stringtemplate:4.0.2'
classpath 'joda-time:joda-time:2.1'
classpath 'commons-io:commons-io:2.4'
}
}
我的问题是,当jar包含在插件消费项目的buildscript的类路径中时,为什么插件项目中“编译”依赖的类没有出现在插件消费项目中。
【问题讨论】:
标签: plugins jar compilation gradle dependencies