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

pec*_*eps 12 android build-process build maven-3 maven

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

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

该项目是使用Maven构建的.

有任何想法吗?

pec*_*eps 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>
Run Code Online (Sandbox Code Playgroud)

在我的构建中:

<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>
Run Code Online (Sandbox Code Playgroud)