Ant targets

Discussion in 'Java' started by Rod, Jun 24, 2005.

  1. Rod

    Rod Guest

    I need to write an ant script which has several targets.

    The script must be able to differentiate, when invoked,
    between two conditions ...call the conditions A or B.

    Based on whether condition A or B is specified, the value
    of several properties will be set differently. These
    properties affect all other targets.

    I envision calling the script something like this :

    ant A targetX ( or ant B targetY )

    Basically, the fact that A was specified would cause
    several properties to be uniquely set and their values available
    to all other targets.

    I am not sure how to accomplish this.

    I know I can create two targets ( A and B ) and
    set the necessary parameters ..the question is then
    how to pickup that second parameter ( targetX ) ...the
    specific target I really wanted to execute !
    ( targetX / targetY in my example above )

    Any ideas ?
     
    Rod, Jun 24, 2005
    #1
    1. Advertising

  2. Rod wrote:
    > I need to write an ant script which has several targets.
    >
    > The script must be able to differentiate, when invoked,
    > between two conditions ...call the conditions A or B.
    >
    > Based on whether condition A or B is specified, the value
    > of several properties will be set differently. These
    > properties affect all other targets.
    >
    > I envision calling the script something like this :
    >
    > ant A targetX ( or ant B targetY )
    >
    > Basically, the fact that A was specified would cause
    > several properties to be uniquely set and their values available
    > to all other targets.
    >
    > I am not sure how to accomplish this.
    >
    > I know I can create two targets ( A and B ) and
    > set the necessary parameters ..the question is then
    > how to pickup that second parameter ( targetX ) ...the
    > specific target I really wanted to execute !
    > ( targetX / targetY in my example above )
    >
    > Any ideas ?
    >


    Well, first of all, ant supports passing multiple targets on the command
    line, like make. So if you have targets A, B, targetX, targetY invoking
    "ant A targetX" is no problem.

    Now this might not be the best way to accomplish what you need. Ant
    <target> tags accept unless and if attributes that can cause the target
    to be skipped even when explicitly invoked. These may be a help to you.

    HTH,
    Ray

    --
    XML is the programmer's duct tape.
     
    Raymond DeCampo, Jun 25, 2005
    #2
    1. Advertising

  3. Rod

    Rod Guest

    Thanks ...that helps.

    Raymond DeCampo wrote:
    > Rod wrote:
    > > I need to write an ant script which has several targets.
    > >
    > > The script must be able to differentiate, when invoked,
    > > between two conditions ...call the conditions A or B.
    > >
    > > Based on whether condition A or B is specified, the value
    > > of several properties will be set differently. These
    > > properties affect all other targets.
    > >
    > > I envision calling the script something like this :
    > >
    > > ant A targetX ( or ant B targetY )
    > >
    > > Basically, the fact that A was specified would cause
    > > several properties to be uniquely set and their values available
    > > to all other targets.
    > >
    > > I am not sure how to accomplish this.
    > >
    > > I know I can create two targets ( A and B ) and
    > > set the necessary parameters ..the question is then
    > > how to pickup that second parameter ( targetX ) ...the
    > > specific target I really wanted to execute !
    > > ( targetX / targetY in my example above )
    > >
    > > Any ideas ?
    > >

    >
    > Well, first of all, ant supports passing multiple targets on the command
    > line, like make. So if you have targets A, B, targetX, targetY invoking
    > "ant A targetX" is no problem.
    >
    > Now this might not be the best way to accomplish what you need. Ant
    > <target> tags accept unless and if attributes that can cause the target
    > to be skipped even when explicitly invoked. These may be a help to you.
    >
    > HTH,
    > Ray
    >
    > --
    > XML is the programmer's duct tape.
     
    Rod, Jun 26, 2005
    #3
  4. Rod

    Rod Guest

    Thanks for reply ...yes, I know about "depends" ...my situation is that
    I need to set the values of several properties based on the "type" of
    run being made ( production, local, etc. ) ...additionally, once the
    -type- of run is identified, one of several targets may be executed
    ....yes, I could expect the user to load a particular properties file
    ...etc, etc. , however, I wanted to keep the ant command as simple as
    possible ...hence two targets ...I just wanted to veify that the
    caller actually passed in two targets before starting any -real- work.
    Currently, I scrapped the two target idea in favor of defining a
    property on the ant call ( i.e. ant -Dtarget="DEV" target1 ) and
    validating that the property was passed in ...seems though that there
    must be a "cleaner" way ....
     
    Rod, Jun 30, 2005
    #4
    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. sri
    Replies:
    0
    Views:
    437
  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