你可以做到這一點使用maven profiles和resource plugin
你需要在你的pom.xml
定義配置文件:
</profiles>
<profile>
<id>variantA</id>
<build>
<!-- custom conf for variant A -->
</build>
</profile>
</profile>
<profile>
<id>variantB</id>
<build>
<!-- custom conf for variant B -->
</build>
</profile>
</profiles>
然後invoque你的構建與所需的配置文件:
mvn clean install -P variantB
而且通過Resource插件,您可以覆蓋整個color.xml文件(在本示例中創建color.xml
文件夾src/templates/resVariantA
):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/res</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${project.basedir}/src/templates/resVariantA</directory>
<targetPath>${project.basedir}/res</targetPath>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
希望它有幫助。