Amrin
Amrin

Reputation: 1515

How do I pass a parameter to an <ant ../> call?

I have a master build file which is calling other build.xml files of different projects.

One of my build file needs a command line argument for the execution

ant -Denv=81 -buildfile build_war.xml

I wrote one task in master build.xml to call build_war.xml

<target name="buildDataExtractor">
  <ant antfile="..\SEFTooling\build_war.xml" inheritall="false" /> 
</target>

How do I pass the "-Denv=81" parameter so that build_war.xml will be executed correctly.

Upvotes: 4

Views: 10056

Answers (1)

Attila
Attila

Reputation: 28762

Try passing properties to the ant task:

<ant antfile="..\SEFTooling\build_war.xml" inheritall="false">
  <property name="env" value="${env}"/>
</ant>

NOTE: in order for this to work properly, you will need to call your main build with ant -Denv=81 or set a property in the main build.xml as such:

<property name="env" value="81"/>

Upvotes: 8

Related Questions