配置特定的摇篮味合用 [英] Config for specific gradle flavor combination
问题描述
我想知道是否有可能提供文件或配置设置特定的风味组组合。例如,我有2味集团,拥有2种不同口味的每个:
I am wondering if it is possible to supply files or configuration settings for a specific flavor group combination. For example, I have 2 flavor groups, with 2 different flavors each:
香精组:版本
- V2
- V3
味组:键入
- 免费
- 完全
在有序的类型,版本我能建立4个不同的我的应用程序的形式:
When ordered "Type", "Version" I am able to build 4 different flavors of my app:
- FreeV2
- FreeV3
- FullV2
- FullV3
和我的源代码树是这个样子:
And my source tree looks like this:
/src
/free
/res
/full
/res
/v2
/java
/res
AndroidManifest.xml (features and permissions for v2 flavors)
/v3
/java
/res
AndroidManifest.xml (features and permissions for v3 flavors)
这正是我想要的,都非常好,我的项目。不过,我希望我能为特定的香味组组合提供文件。例如,我想提供不同的AndroidManifests为FullV3和FullV2。我不认为这是可能的,还是?例如:
This is exactly what I want, and works very well for my project. However, I wish I could provide files for a specific flavor group combination. For example, I want to provide different AndroidManifests for FullV3 and FullV2. I don't think this is possible, or? For example:
/src
/free
/res
/full
/res
/v2
/java
/res
AndroidManifest.xml (features and permissions for v2 flavors)
/v3
/java
/res
AndroidManifest.xml (features and permissions for v3 flavors)
/fullv3
AndroidManifest.xml (features and permissions for full v3 only!)
/fullv2
AndroidManifest.xml (features and permissions for full v2 only!)
我会很高兴能够做到这一点的摇篮构建文件以及
I would be nice to be able to do this in the gradle build file as well:
productFlavors {
free {
packageName ...
flavorGroup "type"
}
full {
packageName ...
flavorGroup "type"
}
v2 {
packageName ...
flavorGroup "version"
}
v3 {
packageName ...
flavorGroup "version"
}
fullv2 {
... <-- specifically for the full-v2 combination
}
fullv3 {
... <-- specifically for the full-v3 combination
}
}
注:一种解决办法是只有1剂组,并明确定义了4口味:
Note: one solution would be to only have 1 flavor group and define the 4 flavors explicitly:
- freeV2
- freeV3
- fullV2
- fullV3
不过,这不是一个可行的解决方案,对我来说,因为我会重复所有的版本具体code为每个版本的自由和充分的味道。
However, this is not a viable solution for me since I would have to duplicate all the version specific code for the free and full flavors of each version.
推荐答案
此功能中添加了版本的 0.7.0 的的 Android插件的摇篮
This functionality was added in version 0.7.0 of the Android plugin for Gradle
http://tools.android.com/tech-docs/new-构建系统&LT; - 截至14年1月6日,这个环节是主动的
http://tools.android.com/tech-docs/new-build-system <--As of 1/6/14, this link is active
您现在可以有一个特定的变异源文件夹,如果你有味道。
You can now have a variant specific source folder if you have flavors.
- 仅适用于应用程序(而不是库或测试)。名称是
的src / flavorDebug /...
或的src / flavor1Flavor2Debug /
- 注意大小写混合的命名,与第一个字母小写。
- Only for app (not library or test). Name is
src/flavorDebug/...
orsrc/flavor1Flavor2Debug/
- Note the camelcase naming, with lower case for first letter.
- 请注意,这是对的所有的尺寸。 的所有组合
- 在它的优先级比单味sourcesets比集结类型高,但低。
- Note that this is for all combinations of all dimensions.
- Its priority is higher than single-flavor sourcesets, but lower than build-types.
更新二零一四年一月三十〇日的
的IntelliJ IDEA v13.0.2 (构建133.696)现在支持在0.7.0做Android的摇篮插件修改
IntelliJ IDEA v13.0.2 (Build 133.696) now supports Android Gradle Plugin changes made in 0.7.0
这篇关于配置特定的摇篮味合用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!