Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override Maven's default resource filter replacement pattern

By default maven will filter resources like this:

<properties>
  <replace.me>value</replace.me>
</properties>

<some-tag>
  <key>${replace.me}</key>
</some-tag>

will get you:

<some-tag>
  <key>value</key>
</some-tag>

Is there a way to override the way maven selects the strings to replace? Specifically, I want to be able to use this:

<some-tag>
  <key>@replace.me@</key>
</some-tag>

to get the same result as above.

like image 671
Matt Campbell Avatar asked Feb 22 '10 23:02

Matt Campbell


2 Answers

Have a look at the delimiters parameter of the resources mojo. Configuring the plugin like this will do the trick:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.4.2</version>
  <configuration>
    <delimiters>
     <delimiter>${*}</delimiter><!-- to keep the default behavior -->
     <delimiter>@</delimiter><!-- to add Ant-like tokens style -->
    </delimiters>
  </configuration>
</plugin>
like image 185
Pascal Thivent Avatar answered Sep 19 '22 15:09

Pascal Thivent


If you would like to use only one approach then disable default delimeters:

<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
  <delimiter>@</delimiter>
</delimiters>
like image 34
eugenn Avatar answered Sep 19 '22 15:09

eugenn