Java/Ant/Condition — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
(нет различий)

Версия 21:01, 31 мая 2010

Condition for file change

   <source lang="java">

<?xml version="1.0"?> <project name="Apache Ant Properties Project" default="compile" basedir=".">

 <fileset dir="." id="uptodate.id">
   <include name="src/jstl/One.java"/>
 </fileset>
 <property name="jstl.src" value="jstl"/>
 <property name="jstl.jar" value="jstl.jar"/>  
 
 <condition property="jstl.src.exists">
   <available file="${jstl.src}" filepath="./src"/>
 </condition>
 <condition property="jstl.jar.exists">
   <available file="${jstl.jar}" filepath="./lib"/>
 </condition>
 <condition property="uptodate">
   <uptodate>
     <srcfiles refid="uptodate.id"/>
     <mapper type="merge" to="./One.java"/>
   </uptodate>
 </condition>
 <target name="checkout-jstl" unless="jstl.src.exists">
   <echo message="Checking out ${jstl.jar}"/>
 </target>
 <target name="build-jstl" depends="checkout-jstl" unless="jstl.jar.exists">
   <echo message="Building ${jstl.jar}"/>
 </target>
 <target name="compile" if="uptodate">
   <echo message="File changed: ${uptodate}"/>
 </target>

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

      </source>
   
  
 
  



Specify condition

   <source lang="java">

<?xml version="1.0"?> <project name="Apache Ant Properties Project" default="do-windows" 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>

      </source>
   
  
 
  



Target based on condition

   <source lang="java">

<?xml version="1.0"?> <project name="Apache Ant Properties Project" default="do-windows" 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>

      </source>