开发者

ant check classpath for jar before taskdef

开发者 https://www.devze.com 2023-01-04 13:59 出处:网络
Is there a way to check the classpath for a jar before executing a taskdef. For example, I want to surround the following with a condition that checks if a jar that ca开发者_如何学Cn has the class or

Is there a way to check the classpath for a jar before executing a taskdef.

For example, I want to surround the following with a condition that checks if a jar that ca开发者_如何学Cn has the class org.hibernate.tool.ant.HibernateToolTask before executing the taskdef

<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"  classpathref="hibernatetool-classpath" />


This should work:

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

Then on any target where you use the hibernatetool task be sure to add depends="hibernatetool".

0

精彩评论

暂无评论...
验证码 换一张
取 消