Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skinning Android app with Maven build profiles

I've got mavenized Android application and customer wants support for the skinning at build time.

For example: mvn clean install -P Developer, mvn clean install -P Customer1, mvn clean install -P Customer2

In other words, different customer needs little bit different set of images, different strings (appName, copyright, etc) and also, some of the elements in layouts should be hidden or shown (Developer profile), so different layouts too.

My first thought was to have folders like res-customer1, res-customer2 in parallel with standard res directory and do the swap in profile definition in pom.xml, also rename it to res, but that doesn't seem to work. I always get original res folder into the build and in this case, duplicates error.

Does this mean that swapping should take place inside of the res? I didn't specify resourceDirectory in configuration of android maven plugin.

I've been googling a lot, but so far, I didn't find anybody with same issue. How to solve it? Is there any general pattern for that?

Many thanks in advance

like image 897
MartinC Avatar asked Mar 14 '12 09:03

MartinC


2 Answers

Based on the answer from yorkw, this solution works for me:

For each profile, resourceDirectory needs to be added into to the configuration of the android maven plugin.

For example:

<resourceDirectory>${project.basedir}/res-customer1</resourceDirectory> <resourceDirectory>${project.basedir}/res-customer2</resourceDirectory>

etc...

like image 138
MartinC Avatar answered Oct 01 '22 12:10

MartinC


If you want to use different assets or resources for different buid profiles and if you even want to merge multiple such directories of each build differently, you can follow this great blog post:

https://ebuddytechblog.wordpress.com/2013/04/08/branded-android-builds-using-maven/

like image 22
Blackhex Avatar answered Oct 01 '22 11:10

Blackhex