Saturday, July 12, 2008

How do I turn a path into an Ant property

http://www.jguru.com/faq/view.jsp?EID=471917

For example:

<path id="tools.class.path">
<pathelement location="${xerces.jar}"/>
<pathelement location="${testlet.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${tools.jar}"/>
<fileset dir="${tools.dir}/lib">
<include name="*.jar" />
<exclude name="testlet.jar"/>
<exclude name="xerces.jar"/>
</fileset>
</path>

It would be nice to be able to print the contents of this path, for debugging. The obvious approach:

<echo message="Classpath is ${tools.class.path}"/>

Doesn't work.

Here's how: First declare a property, referring to the path. Then print the property:

<property name="cp" refid="tools.class.path"/>
<echo message="Classpath is ${cp}"/>

Sphere: Related Content

0 comments: