Android Maven插件和风格 [英] Android Maven Plugin and flavors
问题描述
有人知道使用Android Maven插件是否有可能以及在多大程度上构建不同的应用程序风格?
Does someone know if it's possible, and in which extent, to build different app flavors using the Android Maven Plugin ?
我刚刚看到有一个重命名清单包选项(在此优秀博客文章 btw).
I just saw there was a rename manifest package option in the aapt goal (read in this excellent blog article btw).
如果结合使用此方法和一些常用的Maven配置文件技术,创建2种口味的应用程序是否有任何限制?有什么例子吗?
Are there any limitations to create 2 flavors of an app if you combine this and some usual maven profiles techniques ? Is there any example somewhere ?
提前谢谢!
推荐答案
我使用配置文件来实现这一目标,但我不得不说Gradle的风味在2点上是出色的:
I have used profiles to achieve this but I have to say that the Gradle flavors are superior in 2 points:
上下文
假设您要拥有2个具有不同可绘制对象的应用程序,因此您拥有2个res文件夹
let's say you want to have 2 app with different drawables so you have 2 res folder
-
Gradle Flavor将使用默认文件夹,并将来自Flavor的所有内容覆盖为默认文件夹.
Gradle flavor will use the default folders and overwrite anything that comes from the flavor into the default.
可以在1个命令中将flavor建立到diff目录中
Flavors can be build in 1 command into diff directories
Maven部分示例:
Maven partial example:
<profile>
<id>winter-resources</id>
<properties>
<android.res.dir>${project.basedir}/winter-res</android.res.dir>
</properties>
</profile>
,然后在android-maven-plugin的配置中放入
and in the configuration of the android-maven-plugin you would put
<resourceDirectory>${android.res.dir}</resourceDirectory>
这篇关于Android Maven插件和风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!