Android的构建配置为多个客户多个、客户、Android

2023-09-05 06:33:42 作者:繁华落寂,谁与争锋。

我有一个需要交付给多个客户的Andr​​oid应用程序。 对于每一个客户我有不同的图形和配置XML文件,这些文件中指定的功能和网址。

在构建时,我们应该可以指定该应用程序应建立客户。然后,资源(如图片和运行时配置)适合于指定客户端应建到应用程序。

该项目是用Maven构建。

任何想法?

解决方案

我结束了使用maven配置文件和renameManifestPackage'和Android Maven插件resourceOverlayDirectory属性。

默认RES /目录是由resourceOverlayDirectory具体为每一位客户覆盖。

据工作具有重要意义。

 <! - 配置文件苏黎世 - >
<型材>
  < ID>苏黎世和LT; / ID>
  <性状>
    <客户>苏黎世和LT; /客户>
    < customerPackage> zurich.com< / customerPackage>
    < customerResources>客户/ $ {}客户/ RES< / customerResources>
    < customerApkName> $ {}客户 -  $ {project.artifactId}< / customerApkName>
  < /性状>
< /简介>
 

和在构建我有:

 <建立>
  < sourceDirectory> SRC< / sourceDirectory>

  <! - 生成APK和JAR的名字 - >
  < finalName> $ {customerApkName}  -  $ {project.version}< / finalName>

  < pluginManagement>

    <插件>

  <! - 客户的具体清单和包 - >
  <插件>
    <的groupId> com.jayway.maven.plugins.android.generation2< /的groupId>
    < artifactId的>的maven-的Andr​​oid插件和LT; / artifactId的>
    <结构>
      < renameManifestPackage> $ {customerPackage}< / renameManifestPackage>
      < resourceOverlayDirectory> $ {customerResources}< / resourceOverlayDirectory>
    < /结构>
  < /插件>

    < /插件>

  < / pluginManagement>
 

花椒Android客户端多变体构建实践

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?

解决方案

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>