Ant - available task
Ant -- available task
指定资源在运行时可用的那么变设置property,默认是将property设置为true,否则变不设置property。
实例:
1. 设置a为true, 如果classpath中有org.whatever.Myclass
<available classname="org.whatever.Myclass" property="a"/>
//classname表示在classpath查找指定的类
2. 存在/usr/local/lib目录的情况 设置a为true
<available file="/usr/local/lib" type="dir" property="a"/>
//type的值通常为file或者dir
3. 设置a为true, 当javax.xml.transform.Transformer类在jaxp这个classpath中找到的时候。
...in project ...
<property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
<path id="jaxp" location="${jaxp.jar}"/>
...in target ...
<available classname="javax.xml.transform.Transformer"
classpathref="jaxp" property="a"/>
//classpathref指定使用的classpath
4. 设置a为true, 如果在jvm中找到了资源extratasks.properties
<available property="a" resource="extratasks.properties">
<classpath>
<pathelement location="/usr/local/ant/extra.jar" />
</classpath>
</available>
指定资源在运行时可用的那么变设置property,默认是将property设置为true,否则变不设置property。
实例:
1. 设置a为true, 如果classpath中有org.whatever.Myclass
<available classname="org.whatever.Myclass" property="a"/>
//classname表示在classpath查找指定的类
2. 存在/usr/local/lib目录的情况 设置a为true
<available file="/usr/local/lib" type="dir" property="a"/>
//type的值通常为file或者dir
3. 设置a为true, 当javax.xml.transform.Transformer类在jaxp这个classpath中找到的时候。
...in project ...
<property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
<path id="jaxp" location="${jaxp.jar}"/>
...in target ...
<available classname="javax.xml.transform.Transformer"
classpathref="jaxp" property="a"/>
//classpathref指定使用的classpath
4. 设置a为true, 如果在jvm中找到了资源extratasks.properties
<available property="a" resource="extratasks.properties">
<classpath>
<pathelement location="/usr/local/ant/extra.jar" />
</classpath>
</available>