使用Ant任务更改maven属性

Ane*_*ran 8 maven-2 maven-3 maven maven-ant-tasks

我在pom.xml中设置了maven属性.

<properties>
    <build.start.date>someValue</build.start.date>
</properties>
Run Code Online (Sandbox Code Playgroud)

现在我有一个ant任务执行以下操作:

<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>
Run Code Online (Sandbox Code Playgroud)

这导致:

[echo] Printing Ant Value 2013-03-15_17-53-08
[echo] Printing Maven Value 2013-03-16
Run Code Online (Sandbox Code Playgroud)

但我希望两者都打印:

[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}">
Run Code Online (Sandbox Code Playgroud)

那么问题是如何在ant任务中设置全局maven属性?

Ane*_*ran 15

我找到了这个解决方案.

首先,你需要拥有1.7版本的antrun插件:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
....
</plugin>
Run Code Online (Sandbox Code Playgroud)

然后在配置下,您需要将exportAntProperties设置true(默认情况下为false):

<configuration>
<exportAntProperties>true</exportAntProperties>
Run Code Online (Sandbox Code Playgroud)