Android build configurations for multiple customers

佐手、 提交于 2019-11-30 11:37:23

问题


I have Android application that needs to be delivered to multiple customers. For every customer I have different graphics and configuration XML files which specify features and URLs.

At build time we should be able to specify the customer for which the application should be built. Then resources (like images and run-time configuration) appropriate for the specified client should be built into the app.

The project is build with Maven.

Any ideas?


回答1:


I ended up using maven profiles and 'renameManifestPackage' and 'resourceOverlayDirectory' properties of the android maven plugin.

The default res/ dir is overriden by 'resourceOverlayDirectory' specific for every customer.

It worked out great.

<!-- profile for zurich -->
<profile>
  <id>zurich</id>
  <properties>
    <customer>zurich</customer>
    <customerPackage>zurich.com</customerPackage>
    <customerResources>customers/${customer}/res</customerResources>
    <customerApkName>${customer}-${project.artifactId}</customerApkName>
  </properties>
</profile>

and in the build I have:

<build>
  <sourceDirectory>src</sourceDirectory>

  <!-- the name of the generated apk and jar -->
  <finalName>${customerApkName}-${project.version}</finalName>

  <pluginManagement>

    <plugins>

  <!-- customer specific manifest and package -->
  <plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>maven-android-plugin</artifactId>
    <configuration>
      <renameManifestPackage>${customerPackage}</renameManifestPackage>
      <resourceOverlayDirectory>${customerResources}</resourceOverlayDirectory>
    </configuration>
  </plugin>

    </plugins>

  </pluginManagement>



回答2:


Don't know how well this is supported for Android projects, but the usual way is to define a profile for each customer. In each profile you should override the relevant resource directories with the ones for the specified customer.



来源:https://stackoverflow.com/questions/7552033/android-build-configurations-for-multiple-customers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!