简体   繁体   中英

Building multiple .apk artifacts for different customers with maven

i have to setup an android maven build for a customer, which previously was based on ant.

The base app is a white label implementation and the app is distributed to several third party customers. Each of those customer versions uses the same source code and a set of shared resources. But every customer also has some resources specific to their company (constants, assets, etc).

The structure of my android project looks like this. I only included relevant files/folders and the structure is remained from the ant build:

App
|--src
|--res
|--res-customer1
|--res-customer2
|--pom.xml

This means i have to build multiple .apk artifacts from the same source with different resources. What is the best approach to do this?

The first thing i tried was to use different profiles in my main projects pom for every customer. Then i wrote a shell script to execute all maven builds (1 per customer).

Then i came up with using only one release profile in my main project and passing the customer specific properties via command line. Properties are passed via a shell script, similar to my first approach.

But i'm not happy with that, so i thought about using multiple modules. One per customer. But my problem here is, how i can build those from the same source without copying the source from my main project over to all modules? Or do i have to setup an android project for every customer and refer to my main project as apklib? Will this merge the shared and the customer specific resources?

Is there a best practice to do something like this?

Any other approach is also very welcome.

For only small differences it can be sufficient to just use profiles and a few different properties with resource filter. Profiles however are a bit of a bad pattern in the Maven world and can be hard to work with.

Your hunch to use separate modules for each customer and have the base application be an apklib is correct. I know of several people that have reported on the maven android developers list that this is what they use and works for them. I would personally use that approach in your case as well.

In general I would suggest to ask or at least mention this question on the mailing list .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM