Ant – How to print classpath from path id

In Ant, you can use pathconvert task to print out the classpath from path :

build.xml

  <path id="project.web.classpath">
	<pathelement location="test/lib/junit-4.11.jar"/>
	<pathelement location="test/lib/hamcrest-core-1.3.jar"/>
		
	<fileset dir="${lib.web.dir}">
		<include name="**/*.jar" />
	</fileset>	
  </path>
		
  <target name="print-classpath">
		
	<pathconvert property="classpathInName" refid="project.web.classpath" />
	<echo>Classpath is ${classpathInName}</echo>
		
  </target>

Test :


$ ant print-classpath
Buildfile: /Users/mkyong/Documents/workspace/AntSpringMVC/build.xml

print-classpath:

     [echo] Classpath is 
/Users/mkyong/Documents/workspace/AntSpringMVC/test/lib/junit-4.11.jar:
/Users/mkyong/Documents/workspace/AntSpringMVC/testlib/hamcrest-core-1.3.jar:
......

BUILD SUCCESSFUL
Total time: 0 seconds

References

  1. Ant pathconvert task

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
0 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors
newest oldest most voted