2016-11-04 30 views
0

您好我哈瓦一个名为项目中的三个模块(核心,移动网络)下面的结构:如何使用gradle基于项目版本有条件地构建工件?

A 
    --settings.gradle 
    --build.gradle 
    --core 
    --build.gradle 
    --web 
     --build.gradle 
    --mobile 
     --build.gradle 

我settings.gradle是这样的:

include 'core' 
include 'web' 
include 'mobile' 

有不同的版本已经和直到2.0版本我们提供移动模块,在此之前我们不想构建“移动”模块。现在我有1.0,1.1,1.2,2.0,2.1版本,我们在每次提交代码之前测试并检查编译。我们这样做了:

VERSIONS=("1.0" "1.1" "1.2" "2.0" "2.1) 
for version in "${VERSIONS[@]}"; do (gradle -PspringBootVersion=${version} clean install uploadArchives); done 

这种方式在2.0之前的版本中,它仍然会构建“移动”模块,这当然会失败。我的问题是如何有条件地检查和建立项目?提前致谢。

回答

1
include 'core' 
include 'web' 

if("${springBootVersion}" ==~ /2\.[0-9]) { 
    include include 'mobile' 
} 

这很简单,我只修改settings.gradle上面的方法,然后我得到了正确的结果。

相关问题