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

C

coltrane

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
 
G

Gilbert Rebhan

Hi,

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.
 
C

coltrane

Gilbert said:
Hi,

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.
 
Joined
Jun 3, 2009
Messages
1
Reaction score
0
Or you can simply assign the refid to a property then echo the property

<property name="myproperty" refid="someref"/>
<echo message="${myproperty}/>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top