且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

蚂蚁检查类路径的taskdef前罐子

更新时间:2022-12-06 10:23:48

这应该工作:

 <可用
      财产=hibernatetoolok
      类名=org.hibernate.tool.ant.HibernateToolTask​​
      classpathref =hibernatetool类路径/><目标名称=hibernatetool如果=hibernatetoolok>
  <的taskdef
    NAME =hibernatetool
    类名=org.hibernate.tool.ant.HibernateToolTask​​
    classpathref =hibernatetool类路径/>
< /目标与GT;

然后,你在哪里使用hibernatetool任务一定要添加任何目标取决于=hibernatetool。

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

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