0
我想从gradle.properties
获得我的自定义插件类中的变量值。但我想在apply
方法之外编写和使用它。所以,我写这样的:Groovy:字段属性被声明多次
class VCPlugin implements Plugin<Project> {
private Project project
private Properties properties
properties = new Properties()
properties.load(project.rootProject.file('gradle.properties').newDataInputStream())
def componentClass = properties.getProperty('componentClass')
@Override
void apply(Project project) {
//applying distribution plugin
this.project = project .....
}
}
但是这给编译错误:
Groovy:The field properties is declared multiple times
现在,如果我写的申请方法里面,那么它的工作原理,但我需要在室外使用componentClass
变量申请方法,所以我需要写在外面。任何帮助将不胜感激。
是的,这worked.I在想不同的东西。这个简单的解决方案并没有让我想起。任何方式感谢您的帮助。 – sver