Datamal Blog

Thursday, September 23, 2004

Printing Ant properties for dubugging or logging


Say you have some id that you want the value for :-


<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="tools.class.path is ${tools.class.path}"/>


Does _not_ work. Here's how to do it:-


  • First declare a property, referring to the path.
  • Then print the property:

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


0 Comments:

Post a Comment

<< Home