Java Tutorial/Ant/Condition — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:31, 31 мая 2010
Содержание
and condition in fileset
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="${src.web}/pages">
<and>
<modified>
<param name="cache.cachefile" value="custom.properties"/>
<param name="algorithm.algorithm" value="SHA"/>
</modified>
<type type="file"/>
</and>
</fileset>
</project>
Check condition
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<condition property="is.windows">
<os family="windows"/>
</condition>
<condition property="is.unix">
<os family="unix"/>
</condition>
<target name="do-windows" if="is.windows">
<echo message="This is Windows"/>
</target>
<target name="do-unix" if="is.unix">
<echo message="This is Unix"/>
</target>
</project>
Compile if upto date
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="." id="uptodate.id">
<include name="src/jstl/One.java"/>
</fileset>
<condition property="uptodate">
<uptodate>
<srcfiles refid="uptodate.id"/>
<mapper type="merge" to="./One.java"/>
</uptodate>
</condition>
<target name="compile" if="uptodate">
<echo message="File changed: ${uptodate}"/>
</target>
</project>
Condition properties
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset dir="." id="uptodate.id">
<include name="src/jstl/One.java"/>
</fileset>
<condition property="is.fileset">
<isreference refid="uptodate.id" type="fileset"/>
</condition>
<target name="fileset-prepare">
<echo message="Value of is.fileset = ${is.fileset}"/>
</target>
</project>
or condition with containsregexp
<?xml version="1.0"?>
<project name="Apache Ant Properties Project" basedir=".">
<fileset id="javadoc" dir="${src}">
<include name="shared/**"/>
<include name="stand-alone/**"/>
<include name="web/java/**"/>
<or>
<containsregexp expression="Licensed under the Apache Licen[sc]e"/>
<containsregexp expression="GNU GENERAL PUBLIC LICEN[SC]E"/>
</or>
</fileset>
</project>