Using Echo in Ant to see the classpath

In trying to run unit tests (using JUnit) from Ant some tests were failing due to what appeared to be classpath issues.  I needed to see what all my classpath property contained.  I discovered the pathconvert Ant task.

Here is how I used it in my build file:

<!-- junit.classpath is what I want to see -->
<path id="junit.classpath">
  <fileset dir="lib">
    <include name="**/*.jar"/>
  <path refid="test.mockinputfiles"/>
  <pathelement path="${dir.binaries}" />

<!-- Use pathconvert to put the output in to the echo.classpath property -->
<pathconvert pathsep="${line.separator}| |-- "

<echo message="|-- JUnit Classpath"/>
<echo message="| |"/>
<echo message="| |-- ${echo.classpath}"/>

<junit fork="on" forkmode="once" haltonfailure="false" showoutput="on" printsummary="on" failureproperty="tests.failed">
    <path refid="junit.classpath"/>
  <!-- Other junit properties -->

About stevewall123

I am a Lead Software Engineer in Minneapolis working for Thomson Reuters. I am currently working on projects using Java, JavaScript, Spring, Elasticsearch, Hazelcast, Liquibase and Tomcat. Previously, I used C#, GWT, Grails, Groovy, JMS and JBoss Drools Guvnor. In the past I have worked on projects using J2EE, Swing, Webwork, Hibernate, Spring, Spring-WS, JMS, JUnit and Ant.
This entry was posted in Ant and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s