Wolkenarchitekt
Wolkenarchitekt

Reputation: 21238

Maven Ant Task: Replace property in pom.xml when executing Maven from Ant

In my Ant script, i'm executing Maven like this:

<artifact:mvn pom="${basedir}/pom.xml">
  <arg value="glassfish:deploy" />
</artifact:mvn>

In my pom.xml, there is a property:

<properties>
  <glassfish.home>${env.GLASSFISH}</glassfish.home>
</properties>

This value should be replaced by a value thats provided by the Ant Script. Is it possible to overwrite an existing property in the pom.xml when executing it with the Ant Maven Task? Whats the easiest way to do this?

Upvotes: 1

Views: 1989

Answers (1)

Wolkenarchitekt
Wolkenarchitekt

Reputation: 21238

I forgot that you can simply pass properties to a Maven build on the command line. So to change the property from Ant, i inserted another arg, like this:

<property name="GLASSFISH" value="${basedir}/glassfish"/>
<artifact:mvn pom="${basedir}/pom.xml">
  <arg value="glassfish:deploy" />
  <arg value="-Dglassfish.home=${GLASSFISH}"/>
</artifact:mvn>

Works fine.

Upvotes: 4

Related Questions