Ale*_*oja 7 groovy android gradle build.gradle android-gradle-plugin
所以情况就是这样,在我所拥有的依赖结构的build.gradle文件中
dependencies {
compile 'A'
compile 'B'
}
Run Code Online (Sandbox Code Playgroud)
但是,我希望人们能够只编译A或只编译B,有没有办法知道是否通过返回一个可以在其他地方使用的全局布尔值,在gradle任务中使用依赖关系A?
所以换句话说
if (A was compiled) {
compile A;
} else {
exclude A;
}
Run Code Online (Sandbox Code Playgroud)
您可以像这样获取所有编译依赖项:
def compile = configurations.compile.allDependencies*.with{"$it.group:$it.name:$it.version".toString()}
Run Code Online (Sandbox Code Playgroud)
它将以group:name:version格式返回所有依赖项的列表。然后你就可以使用:
if("org.codehaus.groovy:groovy-all:2.4.7" in compile) {
println "org.codehaus.groovy:groovy-all:2.4.7 was compiled"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
118 次 |
| 最近记录: |