gradle中的java条件依赖
我正在使用gradle进行多项目构建。 我有一个在命令行中注入属性的条件的要求
情景1:
dependencies {
if( ! project.hasProperty("withsources")){
compile 'com.xx.yy:x-u:1.0.2'
}else{
println " with sources"
compile project (':x-u')
}
}
一,。每当我执行渐变运行-Pwithsources
it is printing "withsources"
二,。但是对于gradle run
it is printing "withsources"
情景2:
dependencies {
if( project.hasProperty("withsources")){
compile 'com.xx.yy:x-u:1.0.2'
}else{
println " with sources"
compile project (':x-u')
}
}
一,。每当我执行渐变运行-Pwithsources
it is not printing "withsources"
二,。但是对于gradle run
it is not printing "withsources"
我不知道它总是转到其他循环。这里谁都可以帮忙
# 1 楼答案
如果没有看到完整的构建,我真的不能说你的问题是什么。但你的一般方法是正确的
下面是一个对我有用的小例子:
无财产:
关于财产:
您是否可能在其他地方使用资源定义了?像在gradle.properties中