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:
###########################
############################
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:
Resource Filtering. You can use Maven to perform variable replacement on project resources. When resource filtering is activated, Maven will scan resources for property references surrounded by ${ and }.
Via the resources area in the pom you can filter files from their way src/main/resources to the target/classes folder. The lifecycle of Maven is not influenced by this. I have added resources successfully in . Jar file.
Overview With the default Maven layout, we store resource files under the src/main/resources directory. After a build, Maven moves these files to the build output directory - target/classes. So they become available in the application classpath. There are cases where we have resource files under different directories.
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 :)
You should specify the plugin explicitly in your pom.xml. Implicitly, it is using 2.4.1, which has this issue. You can verify which version maven is using by running maven -X resources:resources.
Version 2.6 fixed this problem.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
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