tags:

views:

206

answers:

1

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.

+2  A: 

To my knowledge, this is not possible, you can't prevent maven from filtering a given property. So either:

  • don't use Maven properties like ${basedir} in your build.xml (if this is possible)
  • don't use Maven filtering but use the Maven Antrun Plugin to replace the ${build.date} and only this property (see this answer)
  • change the delimiters parameter of the resources 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>
    
Pascal Thivent
Thanks again for the help. The 3rd solution was my solution of choice. I had to add <useDefaultDelimiters>false</useDefaultDelimiters>
Benny
@Benny Ah yes, forgot about that (I've updated my answer accordingly).
Pascal Thivent
@Benny BTW, it usually makes sense to [also upvote an accepted answer](http://meta.stackoverflow.com/questions/686/accepting-answer-without-upvoting) ;)
Pascal Thivent