Is it possible to have Ant print out the classpath for a particular target? If so, how?

做~自己de王妃 提交于 2019-11-27 20:01:56

问题


I'm trying to get a target to build that has quite a long list of <pathelement location="${xxx}"/> and <path refid="foo.class.path"/> elements in its <path id="bar.class.path"> element (in the build.xml file). I keep getting "package com.somecompany.somepackage does not exist" errors, and I'm having a hard time chasing down these packages and making sure I've synced them from our repository.

I'm new to this team so I'm unfamiliar with the build, but I would prefer to figure this out myself if possible (so I don't bother the other very busy team members). I have very limited experience with Ant.

I think it would save me quite a bit of time if I could have Ant print out the classpath for the target I'm trying to build.


回答1:


Use the pathconvert task to convert a path to a property

<path id="classpath">
....
</path>

<pathconvert property="classpathProp" refid="classpath"/>

<echo>Classpath is ${classpathProp}</echo>

Docs for pathconvert.




回答2:


This is even easier with versions of Ant > 1.6

<echo>${toString:classpath}</echo>

See http://ant.apache.org/manual/using.html#pathshortcut for more information



来源:https://stackoverflow.com/questions/2430445/is-it-possible-to-have-ant-print-out-the-classpath-for-a-particular-target-if-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!