I have a filter file in src/main/filters/base.properties
with contents:
testProperty=testValue
My POM has resources, filtering, and additional web resources defined (using maven-war-plugin). It also overrides the default filtering delimiter.
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/base.properties</filter>
</filters>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<overwrite>true</overwrite>
<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/more-web-resources</directory>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
All filtering works fine for files located in src/main/resources
. However, a configuration file located in src/main/more-web-resources
is not being filtered properly. So if I have a file src/main/more-web-resources/test.properties
, with contents of:
finalTestProperty=@testProperty@
The final src/main/webapp/test.properties
file looks like:
finalTestProperty=@testProperty@
As opposed to:
finalTestProperty=testValue
So, filtering just isn't working for the additional web resources specified with the maven-war-plugin. What am I missing?
Well, after a night of sleep, I came back to it this morning, built, and the properties are being filtered properly. I made sure my POM and project structure matches my question's exactly, and it does. It's possible I was looking at the original test.properties
and not the built test.properties
.
To be clear, and to address the comments in the question, I did not have to define an additional resource in the <resources/>
section for the more-web-resources
directory, I did not have to (re-)specify the filters in another <filters/>
section inside the maven-war-plugin configuration, and I did not have to (re-)specify the @
delimiter inside the maven-war-plugin. It all just works as I originally expected it to, by using the resources and filters defined in the standard sections of the POM, as well as the maven-resources-plugin.