Recently I have discovered maven resource filtering and saw one note in documentation:
Standard Directory Layout
src/main/filters Resource filter files
I have noticed that maven does not search files declared in <filter>
tag in this directory by default. So what are the benefits of sticking with Maven Layout in this case (except structure uniformity ofcourse)?
Basically you're assuming that the files that are present in src/main/filters (or src/test/filters) are themselves filterable. That assumption isn't correct.
The purpose of the src/main/filters folder is to contain the resource filter files that will be used by Maven during the filtering action.
For instance, imagine that you have the following property defined:
<project>
...
<properties>
<my.property>foo</my.property>
</properties>
...
</project>
And now imagine that you're filtering some folder:
...
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
...
With that definition, any file inside src/main/resources that contains ${my.property} will be replaced by foo.
Now imagine that you don't want to change your POM every time you want to add a new property.
Then is when src/main/filters comes into action. Instead of placing your properties in your POM, you create a file under src/main/filters with your properties and you add a filter to your POM:
<project>
...
<name>Some Project</name>
...
<build>
...
<filters>
<filter>my-filter.properties</filter>
</filters>
...
</build>
...
</project>
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