ant - howto echo <path id=...>

Discussion in 'Java' started by coltrane, Jun 14, 2006.

  1. coltrane

    coltrane Guest

    I am sure this question has been asked and answered but.....

    Is it possible to echo an refid?

    ie.
    <path id="classpath">
    <pathelement location="${common_lib.dir}/xpp3.jar"/>
    <pathelement location="${common_lib.dir}/jibx-run.jar"/>
    <pathelement location="${common_lib.dir}/jibx-bind.jar"/>
    <pathelement location="${common_lib.dir}/oracle/ojdbc.jar"/>
    <pathelement location="${common_lib.dir}/oracle/classes12.jar"/>
    <pathelement location="${tomcat.dir}/common/lib/servlet-api.jar"/>
    </path>
    <echo message="refid classpath"/>

    Thanks for the help

    john
     
    coltrane, Jun 14, 2006
    #1
    1. Advertising

  2. Hi,


    coltrane wrote:
    > I am sure this question has been asked and answered but.....
    >
    > Is it possible to echo an refid?
    > <path id="classpath">
    > <pathelement location="${common_lib.dir}/xpp3.jar"/>
    > <pathelement location="${common_lib.dir}/jibx-run.jar"/>
    > <pathelement location="${common_lib.dir}/jibx-bind.jar"/>
    > <pathelement location="${common_lib.dir}/oracle/ojdbc.jar"/>
    > <pathelement location="${common_lib.dir}/oracle/classes12.jar"/>
    > <pathelement location="${tomcat.dir}/common/lib/servlet-api.jar"/>
    > </path>
    > <echo message="refid classpath"/>


    yup, there's a 'hack' with refid's / id's (undocumented)
    the ant developers say one shouldn't use it, as it could be
    altered in the next ant version.
    that said, i use it a lot ;-)

    just put the line
    <echo message="${toString:classpath}"/>
    instead of <echo message="refid classpath"/>
    and you have it all on one line separated with ';'

    with antcontrib or antelope <for> task you may do things like =

    <for list="${toString:classpath}" param="pathitem" delimiter=";">
    <sequential>
    <echo>pathitem == @{pathitem}${line.separator}</echo>
    </sequential>
    </for>

    [1] http://ant-contrib.sourceforge.net/
    [2] http://antelope.tigris.org/

    bye4now, Gilbert

    P.S.:

    if you're using ant regularly subscribe the ant user list - recommended

    the antelope tasks should have been merged into antcontrib
    but that ain't finished, so i use both.

    there might also be another (somewhat 'cleaner') way via <pathconvert>
    task that ships with ant, just have a look into the ant manual.
     
    Gilbert Rebhan, Jun 14, 2006
    #2
    1. Advertising

  3. coltrane

    coltrane Guest

    Gilbert Rebhan wrote:
    > Hi,
    >
    >
    > coltrane wrote:
    > > I am sure this question has been asked and answered but.....
    > >
    > > Is it possible to echo an refid?
    > > <path id="classpath">
    > > <pathelement location="${common_lib.dir}/xpp3.jar"/>
    > > <pathelement location="${common_lib.dir}/jibx-run.jar"/>
    > > <pathelement location="${common_lib.dir}/jibx-bind.jar"/>
    > > <pathelement location="${common_lib.dir}/oracle/ojdbc.jar"/>
    > > <pathelement location="${common_lib.dir}/oracle/classes12.jar"/>
    > > <pathelement location="${tomcat.dir}/common/lib/servlet-api.jar"/>
    > > </path>
    > > <echo message="refid classpath"/>

    >
    > yup, there's a 'hack' with refid's / id's (undocumented)
    > the ant developers say one shouldn't use it, as it could be
    > altered in the next ant version.
    > that said, i use it a lot ;-)
    >
    > just put the line
    > <echo message="${toString:classpath}"/>
    > instead of <echo message="refid classpath"/>
    > and you have it all on one line separated with ';'
    >
    > with antcontrib or antelope <for> task you may do things like =
    >
    > <for list="${toString:classpath}" param="pathitem" delimiter=";">
    > <sequential>
    > <echo>pathitem == @{pathitem}${line.separator}</echo>
    > </sequential>
    > </for>
    >
    > [1] http://ant-contrib.sourceforge.net/
    > [2] http://antelope.tigris.org/
    >
    > bye4now, Gilbert
    >
    > P.S.:
    >
    > if you're using ant regularly subscribe the ant user list - recommended
    >
    > the antelope tasks should have been merged into antcontrib
    > but that ain't finished, so i use both.
    >
    > there might also be another (somewhat 'cleaner') way via <pathconvert>
    > task that ships with ant, just have a look into the ant manual.
     
    coltrane, Jun 14, 2006
    #3
  4. coltrane

    jeeeff

    Joined:
    Jun 3, 2009
    Messages:
    1
    Or you can simply assign the refid to a property then echo the property

    <property name="myproperty" refid="someref"/>
    <echo message="${myproperty}/>
     
    jeeeff, Jun 3, 2009
    #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,273
  2. john martin
    Replies:
    2
    Views:
    2,243
    john martin
    Apr 7, 2005
  3. ion
    Replies:
    2
    Views:
    431
  4. Replies:
    1
    Views:
    541
    Larry
    Mar 7, 2006
  5. Replies:
    6
    Views:
    903
Loading...

Share This Page