您可以指定集合为你的依赖,比如:
dependencies {
compile ['org.slf4j:slf4j-api:1.7.5','org.apache.commons:commons-lang3:3.1']
}
这意味着你可以使用任何可以产生一个列表。如果你的插件保持像一个文件:
compile.dependencies:
org.slf4j:slf4j-api:1.7.5
org.apache.commons:commons-lang3:3.1
然后,你可以有依赖关系到像项目:
dependencies {
compile file('compile.dependencies').readLines()
}
插件的用户将必须知道将这些行添加到他们的build.gradle。或者,更好的,你可以捆绑组态到一个包含文件,如:
subprojects() {
dependencies {
if (file('compile.dependencies').exists()) {
compile file('compile.dependencies').readLines()
}
if (file('runtime.dependencies').exists()) {
runtime file('runtime.dependencies').readLines()
}
}
}
那么您的用户将只需要使用“从适用:”包括的配置。
我正在寻找Crashlytics在其Android Studio插件中引入的内容。它在build.dependencies中添加了一个新行。 – 2014-10-03 08:19:57