开发者

Android build configurations for multiple customers

开发者 https://www.devze.com 2023-04-08 14:43 出处:网络
I have Android application that needs to be delivered to multiple customers. For every customer I have 开发者_JS百科different graphics and configuration XML files which specify features and URLs.

I have Android application that needs to be delivered to multiple customers. For every customer I have 开发者_JS百科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?


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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号