喜歡你只想創建一組不同的屬性文件的每一個配置,這樣的事情聽起來對我說:
<profiles>
<profile>
<id>group1</id>
<build>
<filters>
<filter>src/main/resources/propertyfile1.txt</filter>
<filter>src/main/resources/propertyfile2.txt</filter>
</filters>
</build>
</profile>
<profile>
<id>group2</id>
<build>
<filters>
<filter>src/main/resources/propertyfile3.txt</filter>
<filter>src/main/resources/propertyfile4.txt</filter>
</filters>
</build>
</profile>
</profiles>
現在每個配置文件爲您提供了資源過濾不同的值。
如果您還需要在POM中的值,你將不得不做一些處理,可能使用類似的maven properties plugin什麼的。把插件定義的肉在主構建元素:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>
和配置文件加載在個人簡介:
<profile>
<id>group1</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<configuration>
<files>
<file>src/main/resources/propertyfile1.txt</file>
<file>src/main/resources/propertyfile2.txt</file>
</files>
</configuration>
</plugin>
</plugins>
</build>
</profile>