蚂蚁在 taskdef 之前检查 jar 的类路径 [英] ant check classpath for jar before taskdef
本文介绍了蚂蚁在 taskdef 之前检查 jar 的类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在执行 taskdef
之前检查 jar 的类路径.
Is there a way to check the classpath for a jar before executing a taskdef
.
例如,我想用一个条件包围以下内容,该条件在执行 taskdef
之前检查是否可以具有 org.hibernate.tool.ant.HibernateToolTask
类的 jar代码>
For example, I want to surround the following with a condition that checks if a jar that can has the class org.hibernate.tool.ant.HibernateToolTask
before executing the taskdef
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="hibernatetool-classpath" />
推荐答案
这应该有效:
<available
property="hibernatetoolok"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernatetool-classpath" />
<target name="hibernatetool" if="hibernatetoolok">
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernatetool-classpath" />
</target>
然后在您使用 hibernatetool 任务的任何目标上,请务必添加depends="hibernatetool".
Then on any target where you use the hibernatetool task be sure to add depends="hibernatetool".
这篇关于蚂蚁在 taskdef 之前检查 jar 的类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文