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

The problem is that I am trying to create a project that has a build.xml file. Basically, I pack my project as a jar of Maven2, and then use the ant installer to install my project.

There is a property in the build.xml file that needs to be filtered with the name build.date, but there are other properties that I don't want to filter, for example $ {basedir}, because it is used by ant, but is replaced by the Maven variable. So, I need to somehow tell Maven to filter $ {build.date}, but not $ {basedir}.

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

Expression Resolution: '$ {basedir}': The following recursive expression loop was detected: [basedir]

Any suggestions would be highly appreciated.

Thanks,

Bj

+7
maven-2 ant
source share
1 answer

As far as I know, this is not possible; you cannot prevent maven filtering for this property. So either:

  • do not use Maven properties like ${basedir} in your build.xml (if possible)
  • don't use Maven filtering, but use Maven Antrun Plugin to replace ${build.date} and only this property (see this answer )
  • change the delimiters parameter of the resource plugin and use for example @build.date@ instead of ${build.date} in your build.xml

     <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.4.2</version> <configuration> <useDefaultDelimiters>false</useDefaultDelimiters> <delimiters> <delimiter>@</delimiter><!-- for Ant-like tokens style --> </delimiters> </configuration> </plugin> 
+7
source share

All Articles