Main Tutorials

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 Author

author image
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

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments