'With Maven, how would I prevent Maven from filtering certain properties but allowing others?

The problem is that I'm trying to build a project that has in its resources a build.xml file. Basically, I package my project as a jar with Maven2, and then use ant installer to install my project.

There is a property in the build.xml file that I need to filter called build.date, but there are other properties that I don't want to filter, like ${basedir}, because it's used by the ant installer but gets replaced by Maven's basedir variable. So, I need to somehow tell Maven to filter ${build.date}, but not ${basedir}.

I tried creating a properties file as a filter with "basedir=${basedir}" as one of the properties, but I get the following error:

Resolving expression: '${basedir}': Detected the following recursive expression cycle: [basedir]

Any suggestions would be much appreciated.

Thanks,

B.J.



Solution 1:[1]

You can define an escape string like e.g.:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
        <escapeString>~~~</escapeString>
    </configuration>
</plugin>

Then use ~~~${basedir} in your build.xml

See https://maven.apache.org/plugins/maven-resources-plugin/examples/escape-filtering.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ferenc Kiss