Your configuration seems correct, but in my experience you may need also <filters>
section.
For example, my application has something similar to:
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/bm.js</include>
</includes>
</resource>
</webResources>
<warName>${war.name}</warName>
</configuration>
</plugin>
</plugins>
<filters>
<filter>src/main/filters/filter-${target.environment}.properties</filter>
</filters>
</build>
The bm.js
file contains a reference to a macro ${my.property}
, which value is set in 2 different files, filter-dev.properties
and filter-qa.properties
. I do have 2 different maven profiles (called dev
and qa
) in the parent POM in which I define the target.environment
property accordingly.
When running mvn package
specifying the profile, the macro in bm.js
will be replaced with the correct value.
I'm not 100% sure this would necessary work with web.xml
, but you can give it a try.