8

I have set a maven property in the pom.xml.

<properties>
    <build.start.date>someValue</build.start.date>
</properties>

Now I have an ant task doing the following:

<loadresource property="build.start">
    <url url="http://someUrl?xpath=/*/id/text()"/>
</loadresource>

<property name="build.start.date" value="${build.start}"/>

<echo>Printing Ant Value ${build.start} </echo>
<echo>Printing Maven Value ${build.start.date}</echo>

This results in:

[echo] Printing Ant Value 2013-03-15_17-53-08
[echo] Printing Maven Value 2013-03-16

But I am expecting both to print:

[echo] Printing Ant Value 2013-03-15_17-53-08
[echo] Printing Maven Value 2013-03-15_17-53-08


I tried <loadresource property="build.start.date">
and
I tried <loadresource property="${build.start.date}">

So the question is how do I set a global maven property inside ant task?

Dmitry
  • 2,943
  • 1
  • 23
  • 26
avijendr
  • 3,958
  • 2
  • 31
  • 46
  • I assume you are running your ant script with maven-antrun-plugin. Looks like you want to override the value that comes from maven, right? Ant Properties are set once and then can never be overridden. – adrianboimvaser Apr 19 '13 at 13:12
  • It's not the ant properties, I need to reset the maven properties, inside the antrun plugin. – avijendr Apr 21 '13 at 19:39
  • `` tries to override an already set property. The property was set by Maven. – adrianboimvaser Apr 22 '13 at 14:03

1 Answers1

15

I found the solution for this one.

First of all you need to have 1.7 version of antrun plugin:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
....
</plugin>

Then under configuration you need to have exportAntProperties to true (false by default):

<configuration>
<exportAntProperties>true</exportAntProperties>
avijendr
  • 3,958
  • 2
  • 31
  • 46