If I pass a variable to ant by doing
ant -Dsomething=blah
How can I refer to it in my build.xml? I tried @something@ and ${something} but neither seem to work.
Ultimately what I am trying to do is set some properties (versions) at compile time.
update: the problem of course turned out to be somewhere else – accepting the most complete looking answer with examples
Don’t you hate it when you over think these things:
Now, I’ll run my program. Notice that I never defined a value for property
fooin mybuild.xml. Instead, I’ll get it from the command line:See. Nothing special at all. You treat properties set on the command line just like normal properties.
Here’s where the fun comes in. Notice that I’ve defined the property
fooin mybuild.xmlthis time around:Now watch the fun:
Now, we’ll set the property
fooon the command line:See the command line overrides the value I set in the
build.xmlfile itself. This way, you can have defaults that can be overwritten by the command line parameters.