ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: How to access value of propertyfile command line inside script
Date Mon, 06 Apr 2009 21:11:15 GMT
My build.xml files include something like this:

<project ...>
    <property name="" value=""/>
    <property file="${"/>

This way, the default name of the build properties file is, so if the user uses that as their build properties
file, they don't have to put anything on the command line. If the user
wants to use a different one, they can give that on the command line,
and the program will use that instead of

     $ ant""

I also include "default" values, so if a user doesn't have a build
properties file, they get the default values. For example:

<project ...>

    <property name="javac.debug.flag" value="false"/>
    <property name="copy.verbose.flag" value="false"/>
    <copy todir="${target.dir}



If the user wants to turn on Java debugging and verbose copying, they
can simply do this:

    $ant -Djavac.debug.flag=true -Dcopy.verbose.flag=true

Otherwise, the build uses the default values I gave it before. Of
course, the user may also use a file too to specify
all of these flags:

    $ ant

Or, they can use put these values into the " file",
and use that. Then, they don't need to use any "-D" parameters on the
command line.

I usually create a file in the build.xml directory called with the various options that the user may
want to set (and their default values). That way, all a user has to do
is copy to and edit the
values they want to change.

Remember that <properties file="..."/> will not fail if the file
mentioned doesn't exist and that <properties> you can override
properties values set in your build.xml file  upon the command line.

On Mon, Apr 6, 2009 at 10:32 AM, goelshek <> wrote:
> When I run ant as follows:
> ant -propertyfile <property file name> <target name>
> e.g.
> ant -propertyfile test
> how do I find out the the name of the properties file that the user passed
> in the command line argument. So my ant script looks like:
> <?xml version="1.0"?>
> <project name="ant-test" basedir=".">
>  <target name="test">
>  <!-- I want to print/access the name of the property file passed on
> command line here.
>         Would like to do something like <echo message="${propertyfile}"/>
> -->
>  </target>
> </project>
> Essentially, is there a place/property where the command line argument is
> stored that can be accessed inside the script? I haven't been able to find
> anything so far in my search.
> Thanks.
> --
> View this message in context:
> Sent from the Ant - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

David Weintraub

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message