Search code examples
javamavenmaven-resources-plugin

Maven resource plugin doesn't filter out customized delimiters nested in ${}


I have a properties file:

property.a=$[value]

I am using maven-resources-plugin with filtering on this property file enabled in order to substitute build variables in there:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
        <delimiters>
            <delimiter>$[*]</delimiter>
        </delimiters>
    </configuration>
</plugin>

Everything works flawlessly, until $[*] token is not nested into ${*} one, like below:

property.a=${VALUE:$[value]}

Assuming value=XXX in Maven properties, I expected to get:

property.a=${VALUE:XXX}

However, Maven resources plugin doesn't substitute $[value] in there, leaving filtered contecnts as-is. I tried enabling supportMultiLineFiltering but it changed nothing. It feels like despite <delimiters> option is set explicitly, plugin treats ${*} as a valid delimiter either, and tries to filter it, without success.

How should I configure maven resources plugin so that it filters the property file contents as expected?


Solution

  • I just realized I missed a configuration option in maven resource plugin, designed specially for controlling default delimiters - useDefaultDelimiters, which is true by default. The configuration below solved the issue:

    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
            <delimiters>
                <delimiter>$[*]</delimiter>
            </delimiters>
            <useDefaultDelimiters>false</useDefaultDelimiters>
        </configuration>
    </plugin>