Ant: Passing attributes to Build.xml
Critter on a previous post asked "if you can pass in attributes to the build.xml file?" From the Terminal this is as easy as adding another argument "-D".
-D<property>=<value>
This will update a property in you build.xml file with the value you passed in
For example you would use something similar to
1ant -buildfile ~/desktop/build.xml -DechoMsg=NewEchoMessage
Putting this into practice here is a sample build.xml which I am going to save to my Desktop
1<?xml version="1.0" encoding="UTF-8"?>
2<project name="myProject" default="runEcho" basedir=".">
3
4 <property name="echoMsg" value="I am the original message" />
5
6 <target name="runEcho">
7<!-- Simply echo's a message to the screen -->
8 <echo message="${echoMsg}"/>
9 </target>
10</project>
2<project name="myProject" default="runEcho" basedir=".">
3
4 <property name="echoMsg" value="I am the original message" />
5
6 <target name="runEcho">
7<!-- Simply echo's a message to the screen -->
8 <echo message="${echoMsg}"/>
9 </target>
10</project>
From the Terminal no run
1ant -buildfile ~/desktop/build.xml -DechoMsg='I overwrite the echo message'
In your terminal window you should see something like
1Buildfile: [PATH TO BUILD FILE]build.xml
2
3runEcho:
4[echo] I overwrite the echo message
5
6BUILD SUCCESSFUL
7Total time: 0 seconds
2
3runEcho:
4[echo] I overwrite the echo message
5
6BUILD SUCCESSFUL
7Total time: 0 seconds
| Tweet |
| If you like what you see on the website and/or this post has helped you out in some way please consider donating to help keep me in beer vodka. The donations are made through Paypal, which accepts almost any credit card or eCheck. |
I've taken the old Model-Glue Ant script you had and modified it a bit.. I've downloaded the latest and placed it on my computer.. made these modification: @modelglueapplicationtemplate@ to all the necessary files..
so now I can call my build.xml and pass in the directory name where I want M-G to be built..