针对多个客户的Android构建配置

时间:2011-09-26 07:49:34

标签: android maven build build-process maven-3

我的Android应用程序需要交付给多个客户。 对于每个客户,我都有不同的图形和配置XML文件,用于指定功能和URL。

在构建时,我们应该能够指定应该为其构建应用程序的客户。然后,应该在应用程序中构建适合指定客户端的资源(如图像和运行时配置)。

该项目是使用Maven构建的。

有什么想法吗?

2 个答案:

答案 0 :(得分:14)

我最终使用maven配置文件和android maven插件的'renameManifestPackage'和'resourceOverlayDirectory'属性。

默认的res / dir被特定于每个客户的'resourceOverlayDirectory'覆盖。

效果很好。

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

在构建中我有:

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

答案 1 :(得分:2)

不知道Android项目支持的程度如何,但通常的方法是为每个客户定义一个配置文件。在每个配置文件中,您应该使用指定客户的资源目录覆盖相关的资源目录。

相关问题