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?
You can actually wrap an ANT project with Maven by using multiple ant run goals as I wrote in a different question. Assuming your existing ant project has clean and build tasks, this might be a useful way of wrapping the project so you can use maven goals and have it map to existing ant code.
Run. The maven-antrun-plugin has only one goal, run . This allows Maven to run Ant tasks. To do so, there must be an existing project and maven-antrun-plugin must have its <target> tag configured (although it would still execute without the <target> tag, it would not do anything).
The Maven Ant Tasks allow several of Maven's artifact handling features to be used from within an Ant build. These include: Dependency management - including transitive dependencies, scope recognition and SNAPSHOT handling. Artifact deployment - deployment to a Maven repository (file integrated, other with extensions)
This plugin provides the ability to run Ant tasks from within Maven. You can even embed your Ant scripts in the POM! It is not the intention of this plugin to provide a means of polluting the POM, so it's encouraged to move all your Ant tasks to a build.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With