如何将多个sourceSets结合 [英] How to combine multiple sourceSets
问题描述
我试图在Eclipse / ANT到Android工作室/摇篮迁移。
我们目前的蚂蚁构建支持N客户(建设 - 目标)和一个客户通过三重皮肤/播放器/客户定义的。
每个皮肤/播放器/客户可能包含SRC,资源,资产,...
I'm trying to migrate from Eclipse/ANT to Android Studio/Gradle. Our current ant-build supports N customers (build-targets) and a customer is defined by a triplet skin/player/customer. Every skin/player/customer may contain src, resources, assets, ...
什么是摇篮模型最好的方法?
What is the best way to model this in Gradle?
我目前为每一位客户打造一个productFlavor如下:
I currently create a productFlavor for every customer as follows
productFlavors {
cust1{
applicationId='com.xyz.cust1'
customer="cust1"
skin="skinX"
player="playerA"
}
cust2{
applicationId='com.xyz.cust2'
customer="cust2"
skin="skinY"
player="playerB"
}
}
但我必须确定在一个紧凑的方式相应sourceSets问题。
but I have problems defining the corresponding sourceSets in a compact way.
我可以写类似
sourceSets.cust1 {
java.srcDir('pool/playerA/src')
res.srcDir('pool/skinX/res')
res.srcDir('pool/playerA/res')
res.srcDir('pool/cust1/res')
assets.srcDir('pool/playerA/assets')
assets.srcDir('pool/skinX/assets')
jniLibs.srcDir('pool/playerA/libs')
}
为每一位客户,但这个结果的N几乎相同sourceSets
for every customer but this results in N almost identical sourceSets
我想preFER有一个单一的,参数化,sourceSets像
I would prefer to have a single, parametrized, sourceSets like
sourceSets {
java.srcDir('pool/${player}/src')
res.srcDir('pool/${skin}/res')
res.srcDir('pool/${player}/res')
res.srcDir('pool/${customer}/res')
assets.srcDir('pool/${player}/assets')
assets.srcDir('pool/${skin}/assets')
jniLibs.srcDir('pool/${player}/libs')
}
这可能吗?
一个选择可以是创建用于每一个球员,皮肤和顾客一个sourceSet和由主sourceSet与玩家,皮肤和客户
One alternative could be to create a sourceSet for every player, skin and customer and create a sourceSet for the productFlavor by combining the main sourceSet with the ones of the player, skin and customer
输入AP preciated!
Input appreciated!
推荐答案
我调查的味维(原名味集团,也被称为多味变型)。
I'd investigate flavor dimensions (formerly known as flavor groups, also known as multi-flavor variants).
利用这些,你会设立了三个维度的味道,对皮肤,播放器,和客户。每个皮肤得到了 productFlavor
在皮肤
尺寸,每个玩家得到一个 productFlavor
在播放
尺寸,并且每个客户得到一个 productFlavor
在客户
尺寸
Using those, you would set up three flavor dimensions, for skin, player, and customer. Each skin gets a productFlavor
in the skin
dimension, each player gets a productFlavor
in the player
dimension, and each customer gets a productFlavor
in the customer
dimension.
您将不得不像 assembleSkinxPlayeraCust1Debug
任务,这会从 skinx
建立一个应用程序, playera
, cust1
和调试
sourcesets。
You would then have tasks like assembleSkinxPlayeraCust1Debug
, which would build an app from skinx
, playera
, cust1
, and debug
sourcesets.
这篇关于如何将多个sourceSets结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!