我有一个项目可能会根据所选配置文件采用不同的来源/资源。有些配置文件是互斥的,有些应该是可组合的,例如,在下面的代码段中定义的配置文件local
应该wildfly
是可组合的
<profiles>
<profile>
<id>local</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>add-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>profiles/local/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>profiles/local/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>wildfly</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>add-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>profiles/wildfly/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>profiles/wildfly/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
如果我在 Eclipse 下执行此操作,我注意到实际上只应用了后者 - 我只看到wildfly
配置文件中定义的源/资源。
同样在生成的完整 POM 中,我注意到仅wildfly
应用了后者 ( ) 配置文件的配置,因此删除了local
配置文件中定义的源和资源。
这是插件应该工作的方式,还是我错过了什么?