<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> <TITLE>Ant-contrib Tasks: OutOfDate</TITLE> <META NAME="GENERATOR" CONTENT="OpenOffice.org 644 (Linux)"> <META NAME="CREATED" CONTENT="20030314;12023500"> <META NAME="CHANGED" CONTENT="20030319;15211400"> </HEAD> <BODY LANG="en-US" DIR="LTR"> <H1>OutOfDate</H1> <P>Task definition for the <CODE>outofdate</CODE> task. This is an extension of uptodate which allows multible targets and contains an embedded <parallel> or <sequential> element. If any of the target file's dates are earlier than any of the source file's dates, then the specified <parallel> or <sequential> block is executed. The task may also contain mappers to map source files to corresponding target files. </P> <H2>Parameters</H2> <TABLE WIDTH=100% BORDER=1 CELLPADDING=2 CELLSPACING=0> <COL WIDTH=0> <COL WIDTH=0> <COL WIDTH=0> <TR> <TH> <P>Attribute</P> </TH> <TH> <P>Description</P> </TH> <TH> <P>Required</P> </TH> </TR> <TR VALIGN=TOP> <TD> <P>property</P> </TD> <TD> <P>The name of the property to set to the contents of the <CODE>value</CODE> parameter if any of the target files are out of date</P> </TD> <TD> <P ALIGN=LEFT>No</P> </TD> </TR> <TR VALIGN=TOP> <TD> <P>value</P> </TD> <TD> <P>The value to set the property specified by the parameter <CODE>property</CODE> to, if any of the target files are out of date</P> </TD> <TD> <P ALIGN=LEFT>No, defaults to "true"</P> </TD> </TR> <tr> <td valign="top">force</td> <td valign="top"> Force outofdate ("true"/"false"). Default is "false". </td> <td valign="top">No</td> </tr> <tr> <td valign="top">verbose</td> <td valign="top"> Set vebose logging level for this task ("true"/"false"). Default is "false". </td> <td valign="top">No</td> </tr> <TR VALIGN=TOP> <TD> <P>outputsources</P> </TD> <TD> <P>The name of a property to set containing the sources that are newer that their corresponding targets.</P> </TD> <TD> <P ALIGN=LEFT>No</P> </TD> </TR> <TR VALIGN=TOP> <TD> <P>outputtargets</P> </TD> <TD> <P>The name of a property to set containing the targets that are outofDate with respect to their corresponding sources.</P> </TD> <TD> <P ALIGN=LEFT>No</P> </TD> </TR> <TR VALIGN=TOP> <TD> <P>alltargets</P> </TD> <TD> <P>The name of a property to set containing all the targets. This is usefull for debugging mapper nested elements.</P> </TD> <TD> <P ALIGN=LEFT>No</P> </TD> </TR> <TR VALIGN=TOP> <TD> <P>separator</P> </TD> <TD> <P>The separator used to separate the files in the properties above. If a filename contains the separator, double quotes will be placed aroudnd the filename.</P> </TD> <TD> <P ALIGN=LEFT>No, defaults to “ “</P> </TD> </TR> <TR VALIGN=TOP> <TD> <P>outputsourcespath</P> </TD> <TD> <P>The id of a path to create containing the source files that are outofdate.</P> </TD> <TD> <P ALIGN=LEFT>No</P> </TD> </TR> <TR VALIGN=TOP> <TD> <P>outputtargetspath</P> </TD> <TD> <P>The id of a path to create containing the target files that need to be updated.</P> </TD> <TD> <P ALIGN=LEFT>No</P> </TD> </TR> <TR VALIGN=TOP> <TD> <P>alltargetspath</P> </TD> <TD> <P>The id of a path to create containing all the target files. </P> </TD> <TD> <P ALIGN=LEFT>No</P> </TD> </TR> </TABLE> <H2>Attributes specified as nested elements</H2> <P><B>sourcefiles</B> - The list of files which are source files. This element is required. <BR><BR><B>targetfiles</B> - The list of files which are target files. </P> <P>Both of these nested elements are <A HREF="http://ant.apache.org/manual/using.html#path">Path</A> elements which are are used to select sets or lists of files or directories</P> <p>The <i>sourcefiles</i> may contain no files. In this case, outofdate will check the existance of the <i>targetfiles</i>.</p> <P><B>mapper –</B> This is used to map source files to target files.</P> As well as the regular attributes for mapper, there is a extra attribute to specify the relative directory of the sources.<p> <table cellspacing="0" cellpadding="2" border="1"> <tr> <td valign="top"><b>Attribute</b></td> <td valign="top"><b>Description</b></td> <td valign="top"><b>Required</b></td> </tr> <tr> <td valign="top">dir</td> <td valign="top"> The directory to the sources are relative to for the mapper. Default is ${base.dir}. </td> <td valign="top">No</td> </tr> </table> <P>There may be a number of mapper nested elements. <P><B>deletetargets –</B> This is used to delete targets if the corresponding sources are outofdate. </P> <table cellspacing="0" cellpadding="2" border="1"> <tr> <td valign="top"><b>Attribute</b></td> <td valign="top"><b>Description</b></td> <td valign="top"><b>Required</b></td> </tr> <tr> <td valign="top">all</td> <td valign="top"> Whether to delete all the targets ("true"/"false"). Defaults to "false". </td> <td valign="top">No</td> </tr> <tr> <td valign="top">quiet</td> <td valign="top"> Do not display diagnostic messages when deleting targets ("true"/ "false"). Defaults to false. When set to "true", if a file or directory cannot be deleted, no error is reported. This setting emulates the -f option to the Unix rm command. Default is "false". Setting this to "true" implies setting failonerror to "false" </td> <td valign="top">No</td> </tr> <tr> <td valign="top">failonerror</td> <td valign="top"> Controls whether an error (such as a failure to delete a file) stops the build or is merely reported to the screen. Only relevant if quiet is "false". Default is "true". Controls whether a failure to delete a target stops the build or is merely reported to the screen. </td> <td valign="top">No</td> </tr> </table> </P> <H2>Examples</H2> <P>The following example creates the file ${jrun.file} if is older that build.xml, or any file in ${lib.dir}.</P> <PRE> <outofdate> <sourcefiles> <pathelement path="build.xml"/> <fileset dir="${lib.dir}"/> </sourcefiles> <targetfiles path="${jrun.file}"/> <sequential> <mkdir dir="${build.bin.dir}"/> <echo file="${jrun.file}" message="java -cp ${jrun.path} $*"/> <chmod file="${jrun.file}" perm="ugo+rx"/> </sequential> </outofdate> </PRE><P> The following example check the generated files, MODULE.IDS, acme_agent_mib.h, acme_agent_mib.cpp are older that miblist.txt, or any file in ${mib.src}, and if so an embedded shellScript is invoked to update the files.</P> <PRE> <outofdate> <sourcefiles> <pathelement path="${agent.src}/miblist.txt"/> <fileset dir="${mib.src}"/> </sourcefiles> <targetfiles> <pathelement path="${rep}/MODULE.IDS"/> <pathelement path="${gen-agent}/acme_agent_mib.h"/> <pathelement path="${gen-agent}/acme_agent_mib.cpp"/> </targetfiles> <sequential> <shellscript shell="bash" dir="${agent.src}"> classname=com.agentpp.agentgen.AgentGenConsole h1=${gen-agent}/acme_agent_mib.x ag() { java -cp ${lib.dir}/agentgen.jar $classname ${rep} $@ } ag initialize ag load miblist.txt ag generate ACME-AGENT-MIB h > $h1 (head -16 $h1; echo "using namespace Agentpp;"; tail +16 $h1) > ${gen-agent}/acme_agent_mib.h ag generate ACME-AGENT-MIB c >\ ${gen-agent}/acme_agent_mib.cpp </shellscript> </sequential> </outofdate></PRE><P> The following example sets the project <I>manual.outofdate</I> if any of the xml files are newer than index.html, or if any of the xml files are newer than their corresponding .html file. A path identified by <I>sources.path</I>, is created which contains the sources that fullfilled these conditions.</P> <PRE> <outofdate property="manual.outofdate" outputsourcespath="sources.path"> <sourcefiles> <fileset dir="${src.manual}" includes="**/*.xml"/> </sourcefiles> <targetfiles path="${doc.manual}/index.html"/> <mapper type="glob" dir="${src.manual}" from="*.xml" to="${doc.manual}/*.html"/> </outofdate> </PRE> <P> The following assumes that there is a program called <I>gengrammer</I> that takes a grammer file as an input and generates a .h and a .c file in the current directory.</P> <PRE> <outofdate property="manual.outofdate" outputsources="grammer.sources"> <sourcefiles> <fileset dir="${src.grammer}" includes="**/*.y"/> </sourcefiles> <mapper type="glob" dir="${src.grammer}" from="*.y" to="${gen.grammer}/*.c"/> <mapper type="glob" dir="${src.grammer}" from="*.y" to="${gen.grammer}/*.h"/> <sequential> <shellscript shell="bash"> cd ${gen.grammer} for g in ${grammer.sources} do gengrammer $g done </shellscript> </sequential> </outofdate> </PRE> <HR> <P ALIGN=CENTER>Copyright © 2003 Ant-Contrib Project. All rights Reserved.</P> </BODY> </HTML>