Example:
I would hope and expect the following pom to deploy both profileResources and commonResources when the "profile" profile is active, but it deploys only profileResources. What can I do to achieve the desired effect?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<packaging>war</packaging>
<version>0.0.0</version>
<profiles>
<profile>
<id>profile</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/profileResources</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/commonResources</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
Working Version (for future reference)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<packaging>war</packaging>
<version>0.0.0</version>
<profiles>
<profile>
<id>profile</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/profileResources</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources combine.children="append">
<resource>
<directory>src/main/commonResources</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
Git Word Diff Between Broken and Working Versions
diff --git a/tmp/broken-pom.xml b/tmp/working-pom.xml
index 2fd9bbf..b04683f 100644
--- a/tmp/broken-pom.xml
+++ b/tmp/working-pom.xml
@@ -31,5 +31,5 @@
<version>2.1.1</version>
<configuration>
<webResources{+ combine.children="append"+}>
<resource>
<directory>src/main/commonResources</directory>
Try adding combine.children="append"
to the resources
element in the non-profile plugin- I think it's messing up because the default behaviour means the profile settings will override anything with the same name higher up the tree. See http://maven.apache.org/pom.html#Plugins for details on merging/appending attributes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With