Maven - resource filtering : implications of the @ symbol in resource files

Dinuk picture Dinuk · Oct 29, 2010 · Viewed 12.4k times · Source

I am using the Maven assembly plugin to prepare some configuration artifacts for different environments, and I am using resource filtering to substitute parameter values.

I came across a weird behaviour where I had a property file with the contents as follows:


###########################

# [email protected] #

############################

env.name=${replacement.value}


The presence of the '@' symbol for the author's e-mail was causing all property references to be ignored.

I have tried looking for documentation as to why this happens - but cannot find anything that answers this behaviour. Any helpful pointers to documention or an explanation would be much appreciated.

For reference:

  1. Maven version: 2.2.1
  2. Maven Assembly Plugin version: 2.2

Answer

Pascal Thivent picture Pascal Thivent · Oct 30, 2010

I have tried looking for documentation as to why this happens - but cannot find anything that answers this behaviour. Any helpful pointers to documentation or an explanation would be much appreciated.

This is not documented in the filtering section of the Maven Assembly Plugin but it looks like it uses the same default delimiters as the Maven Resources Plugin which are:

<build>
  ...
  <plugin>
    ...
    <configuration>
      ...
      <delimiters>
        <delimiter>${*}</delimiter>
        <delimiter>@</delimiter>
      </delimiters>

So the following would be filtered as well:

[email protected]@

And this also explains why a single @ in the email address is causing troubles (the plugin never finds the end delimiter).

It is possible to configure the delimiters and an escape string, just as it is when using the Maven Resources Plugin. The Maven Assembly Plugin documentation for the single goal provides the details.

A cheap workaround, for this particular email address situation, would be to avoid using a single @ in the file to filter:

##############################
# author.name aT company.com #
##############################

env.name=${replacement.value}

And as a benefit, you'll avoid spam :)