OutOfDate

Task definition for the outofdate 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.

Parameters

Attribute

Description

Required

property

The name of the property to set to the contents of the value parameter if any of the target files are out of date

No, if a <parallel> or <sequential> block has been specified

value

The value to set the property specified by the parameter property to, if any of the target files are out of date

No, defaults to "true"

outputsources

The name of a property to set containing the sources that are newer that their corresponding targets.

No

outputtargets

The name of a property to set containing the targets that are outofDate with respect to their corresponding sources.

No

alltargets

The name of a property to set containing all the targets. This is usefull for debugging mapper nested elements.

No

separator

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.

No, defaults to “ “

outputsourcespath

The id of a path to create containing the source files that are outofdate.

No

outputtargetspath

The id of a path to create containing the target files that need to be updated.

No

Attributes specified as nested elements

sourcefiles - The list of files which are source files. This element is required.

targetfiles - The list of files which are target files.

Both of these nested elements are Path elements which are are used to select sets or lists of files or directories

mapper – This is used to map source files to target files.

There may be a number of mapper nested elements.

Examples

The following example creates the file ${jrun.file} if is older that build.xml, or any file in ${lib.dir}.

        <outofdate>
          <sourcefiles>
            <pathelement path="build.xml"/>
            <fileset dir=”${lib.dir}”/>
          </sourcefiles>
          <targetfiles>
            <pathelement path="${jrun.file}"/>
          </targetfiles>
          <sequential>
            <mkdir dir="${build.bin.dir}"/>
            <echo file="${jrun.file}" message="java -cp ${jrun.path} $*"/>
            <chmod file="${jrun.file}" perm="ugo+rx"/>
          </sequential>
        </outofdate> 

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.

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

The following example sets the project manual.outofdate 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 sources.path, is created which contains the sources that fullfilled these conditions.

        <outofdate property="manual.outofdate" outputsourcespath=”sources.path”>
            <sourcefiles>
                <fileset dir="${src.manual}" includes="**/*.xml"/>
            </sourcefiles>
            <targetfiles>
                <pathelement path="${doc.manual}/index.html"/>
            </targetfiles>
            <mapper type=”glob” from="${src.manual}/*.xml" to="${doc.manual}/*.html"/>
         </outofdate>

The following assumes that there is a program called gengrammer that takes a grammer file as an input and generates a .h and a .c file in the current directory.

         <outofdate property="manual.outofdate"
                    outputsources=”grammer.sources”>
            <sourcefiles>
                <fileset dir="${src.grammer}" includes="**/*.y"/>
            </sourcefiles>
            <mapper type=”glob” from=”${src.grammer}” to=”${gen.grammer}/*.c”/>
            <mapper type=”glob” from=”${src.grammer}” to=”${gen.grammer}/*.h”/>
            <sequential>
                <shellscript shell="bash">
                    cd ${gen.grammer}
                    for g in ${grammer.sources}
                    do
                       gengrammer $g
                    done
                </shellscript>
            </sequential>
         </outofdate>
    

Copyright © 2003 Ant-Contrib Project. All rights Reserved.