Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Ant build.xml

  • 19-09-2005 8:44am
    #1
    Registered Users, Registered Users 2 Posts: 194 ✭✭


    I need to pass command-line arguments into my build.xml

    Any idea how to do this?

    I know there's an <arg> tag but afaik that's used for passing arguments to an executable.

    Cheers

    -pb


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    http://ant.apache.org/manual/

    The two you are looking for are...

    ant build.xml -D<property>=<value>

    Creates a property with set value. If you want to load a properties file then..

    ant build.xml -propertyfile <name>

    Personally I create a properties file and reference it in the build xml like so..

    <property file="build.properties"/>

    In that file I put all my properties.

    I also tell it to reference the system properties (SET) with this..
    <property environment="env"/>

    Then reference System environment variables like so
    ${env.PATH}
    ${env.CLASSPATH}


  • Registered Users, Registered Users 2 Posts: 194 ✭✭pbarry


    Cheers Hobbes,

    A little bit more detail on what I'm doing:

    I have a CommandLineParser class which defines 3 command-line options(eg. -a, -b, -c).

    I then have a target in my build.xml - "my-target".

    So in the cmd, when I want to build the target I want to be able to use the following:

    ant my-target -a argument1

    argument1 will be used to set a configuration variable in the application.

    The CommandLineParser is executed within "my-target".

    Is this the correct flow in order to achieve the above? Can I pass argument1 from "my-target" to the (String[] args) of CommandLineParser's main method?



    Cheers


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    shouldn't it be ...

    ant build.xml my-target -Dcmdarg="-a argument1"

    then run your command line parser with ${cmdarg} as the argument.


  • Registered Users, Registered Users 2 Posts: 194 ✭✭pbarry


    Cheers Hobbes,

    I'll give it a go so.....I'm a bit flaky on Ant so just trying to piece it together.

    -pb


  • Registered Users, Registered Users 2 Posts: 194 ✭✭pbarry


    Ok,

    So I got that working Hobbes, nice one.

    Next Q is this:

    I now have a build.xml and two forked scripts build1.xml and build2.xml.

    How can I execute the child scripts from the main script build.xml?

    Is it a case of using:
    <java classname="build2 class name" dir="${YYY}/.." fork="true" failonerror="true"><classpath>
    <pathelement location="${XXX}"/>
    <fileset dir="${TTT}" includes="*.jar" excludes="ant.jar" />
    </classpath>	
    </java>
    

    Cheers

    -pb


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    use ANT or ANTCALL commands. Try the manual its pretty good.

    example:

    <ant antfile="build2.xml" dir="directory"/>


  • Registered Users, Registered Users 2 Posts: 194 ✭✭pbarry


    Cool,

    I've been crawling through the manual but its hard to find what you need when you don't know what you're looking for!

    appreciate it hobbes..........


Advertisement