JGekp
JGekp

Reputation: 33

maven resource filter xml

I am trying to use respurce filtering for .properties & .xml files. I am having a ${variable} value and maven replaces the ${--} with its real value. I am able to achieve this for properties files, but for .xml file I am not sure how to do it.

My pom.xml

<resource>
<directory>${basedir}/../</directory>
<filtering>true</filtering>
<includes>
 <include>filename/*.properties</include>
</includes>
  </resource>

My properties file

value=${value}

I am kind of following this approach http://piotrnowicki.com/2012/10/filtered-resources-in-maven/

Similar question was posted:

Upvotes: 1

Views: 748

Answers (2)

JGekp
JGekp

Reputation: 33

I was able to resolve this by adding an include tag:

filename/*.xml

Thanks everyone for your help

Upvotes: 0

Puce
Puce

Reputation: 38132

If you like you could use the SoftSmithy Parent POM as your parent POM.

<parent>
    <groupId>org.softsmithy</groupId>
    <artifactId>softsmithy-parent</artifactId>
    <version>3.0</version>
</parent>

The SoftSmithy Parent POM is a general purpose parent POM with many reasonable defaults.

E.g. it configures all files in src/main/resources and src/test/resources to be filtered and all files in src/main/resources-bin and src/test/resources-bin not to be filtered (intended for binary files such as images or text files you don't want to filter).

It might be a good starting point.

The SoftSmithy Parent POM is available on GitHub.

Upvotes: 1

Related Questions