6
votes

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

2
Have you actually tried specify resourceDirectory in configuration of android maven in each profile? for example <resourceDirectory>${project.basedir}/res-custom1</resourceDirectory>. This should work as you expected.yorkw
I'm working on it, looks like you're right, my friend. I will come back with definitive answer, but many many thanks.MartinC
OK, it works, you made my day, yorkw :) Thank you very much.MartinC
welcome to stackoverflow. consider add an answer to you own question yourself.yorkw

2 Answers

6
votes

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...

1
votes

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/