【发布时间】:2014-02-07 14:45:57
【问题描述】:
基本上我想做的是定义一组依赖项,然后在各个构建脚本中调用一个函数或类似的东西来添加它们。基本上是这样的:
/build.gradle
apply plugin: 'base' // To add "clean" task to the root project.
subprojects {
apply from: rootProject.file('common-deps.gradle')
}
/settings.gradle
include ":sub-project"
/common-deps.gradle
def addHttpComponents() {
dependencies {
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.3'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.1'
}
}
那么,如果我想将 HttpComponents 添加到我的构建中。我希望能够将我的子项目的构建文件编写为:
/sub-project/build.gradle
apply maven
apply java
addHttpComponents()
由于上面的文件无法运行,有没有办法做到这一点。还是我完全走错了路。
【问题讨论】:
标签: dependencies gradle dependency-management