访问build.gradle的部分插件中的变量 [英] Accessing variables in build.gradle's section plugins
问题描述
插件{
id'java '
id'war'
id'eclipse-wtp'
idcom.moowork.gruntversion $ grunt_version
idorg.akhikhl.grettyversion $ gretty_version
}
但这不起作用。任何建议?
通过深入挖掘gradle文档,我发现了这一点:
表单为:
插件{
id«插件ID»版本«插件版本»
}
其中插件版本和插件ID必须是不变的,字面的,字符串。没有其他声明是允许的;它们的存在将导致编译错误。
plugins {}块也必须是
buildscript中的顶级语句。它不能嵌套在另一个构造中(例如,
if语句或for循环)。
...
如果新语法的限制是禁止的,推荐的方法是使用buildscript块来应用插件。 b $ b
我想我会试试看...
I want to use variables in section Plugins (from gradle.properties)
plugins {
id 'java'
id 'war'
id 'eclipse-wtp'
id "com.moowork.grunt" version $grunt_version
id "org.akhikhl.gretty" version $gretty_version
}
but this won't work. Any suggestions?
By digging deeper in the gradle docs I found this:
The form is:
plugins { id «plugin id» version «plugin version» }
Where «plugin version» and «plugin id» must be constant, literal, strings. No other statements are allowed; their presence will cause a compilation error.
The plugins {} block must also be a top level statement in the buildscript. It cannot be nested inside another construct (e.g. an if-statement or for-loop).
...
If the restrictions of the new syntax are prohibitive, the recommended approach is to apply plugins using the buildscript {} block.
I think I'll give it a try...
这篇关于访问build.gradle的部分插件中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!