I have a project which may take different sources / resources based on the selected profiles. Some profiles are mutually exclusive, some should be combinable, for example the profiles local
and wildfly
defined in the snippet below should be combinable
<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>
If I do this under eclipse I notice that only the latter is actually applied - I only see the sources / resources defined in the wildfly
profile.
Also in the resulting complete POM I notice that only the latter (wildfly
) profile's configuration is applied, thus removing the sources and the resource defined in the local
profile.
Is this the way the plugin is supposed to work, or am I missing something?