我有一个 Android 应用程序需要交付给多个客户。
对于每个客户,我都有不同的图形和配置 XML 文件,其中指定了功能和 URL。
在构建时,我们应该能够指定应为其构建应用程序的客户。然后,应将适合指定客户端的资源(例如图像和运行时配置)内置到应用程序中。
该项目是使用 Maven 构建的。
有任何想法吗?
我最终使用了 maven 配置文件以及 android maven 插件的“renameManifestPackage”和“resourceOverlayDirectory”属性。
默认的 res/ 目录被特定于每个客户的“资源覆盖目录”覆盖。
效果很好。
<!-- 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)