Arguments with ANT

Discussion in 'Java' started by Eric Farraro, Apr 7, 2008.

  1. Eric Farraro

    Eric Farraro Guest

    I've been looking for a way to pass arguments to ANT, but have so far
    been unsuccessful. I figured out how to pass them from the command
    line:

    ant -buildfile -Dmyarg=abc

    .... but what I'd like to do, is have an ANT script call a different
    ANT script, and pass the arguments along. So far, I have not figured
    out how to pass arguments to an ANT script, from within another ANT
    script. What I have is something like this:

    (Inside build.xml):

    <ant dir="${ant.exec.directory}" antfile="${ant.script.name}"
    target="main" inheritAll="true"/>

    I'd like to pass any arguments to 'ant.script.name' that 'build.xml'
    receives. For instance, if there was a 'parameter' attribute, I could
    use something like that.

    Any suggestions?
     
    Eric Farraro, Apr 7, 2008
    #1
    1. Advertising

  2. Eric Farraro

    Roedy Green Guest

    On Mon, 7 Apr 2008 10:05:39 -0700 (PDT), Eric Farraro
    <> wrote, quoted or indirectly quoted someone who
    said :

    >... but what I'd like to do, is have an ANT script call a different
    >ANT script, and pass the arguments along. So far, I have not figured
    >out how to pass arguments to an ANT script, from within another ANT
    >script. What I have is something like this:


    You can put things in the set environment. I put the jar signing
    password in there, for example.

    I get at it like this:

    <!-- get _your_ password from set jarsignerpassword=sesame -->
    <!-- get _your_ code-signing certificate from set
    cert=mindprodcert2008dsa -->
    <property environment="env" />
    <signjar jar="${jar.file}"
    alias="${env.cert}" storepass="${env.jarsignerpassword}" />



    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Apr 7, 2008
    #2
    1. Advertising

  3. Eric Farraro

    Arne Vajhøj Guest

    Eric Farraro wrote:
    > I've been looking for a way to pass arguments to ANT, but have so far
    > been unsuccessful. I figured out how to pass them from the command
    > line:
    >
    > ant -buildfile -Dmyarg=abc
    >
    > ... but what I'd like to do, is have an ANT script call a different
    > ANT script, and pass the arguments along. So far, I have not figured
    > out how to pass arguments to an ANT script, from within another ANT
    > script. What I have is something like this:
    >
    > (Inside build.xml):
    >
    > <ant dir="${ant.exec.directory}" antfile="${ant.script.name}"
    > target="main" inheritAll="true"/>
    >
    > I'd like to pass any arguments to 'ant.script.name' that 'build.xml'
    > receives. For instance, if there was a 'parameter' attribute, I could
    > use something like that.


    inheritAll="true" will pass all existing properties.

    To pass new properties use:

    <ant dir="${ant.exec.directory}" antfile="${ant.script.name}"
    target="main" inheritAll="true">
    <property name="myarg" value="abc"/>
    </ant>

    Arne
     
    Arne Vajhøj, Apr 8, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Bedford
    Replies:
    6
    Views:
    2,272
  2. Roy Smith
    Replies:
    1
    Views:
    5,979
    John C. Bollinger
    Apr 30, 2004
  3. john martin
    Replies:
    2
    Views:
    2,243
    john martin
    Apr 7, 2005
  4. Replies:
    1
    Views:
    540
    Larry
    Mar 7, 2006
  5. Replies:
    6
    Views:
    901
Loading...

Share This Page