ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "W. Sean Hennessy" <shenne...@goldenhourdata.com>
Subject RE: example behavior of <outofdate> using <mapper>?
Date Mon, 09 Jun 2003 15:09:37 GMT
The directory is specified by refid to the following fileset:

   <fileset id="srcdoc.fs.id" dir="${src.doc.dir}" >
      <patternset refid="srcdoc.ptnset.id"/>
   </fileset>

-----Original Message-----
From: peter reilly [mailto:peter.reilly@corvil.com]
Sent: Monday, June 09, 2003 1:18 AM
To: Ant Users List
Subject: Re: example behavior of <outofdate> using <mapper>?


My doc on outofdate is not the best when using mapper.
The core bit missing from your build file is the "dir" attribute
to the mapper sub-element of outofdate.
mapper in "outofdate" needs to be told the directory that
the from files are relative to.

A simplified example:

<project name="t" default="t">
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
  <property name="build.dir" value="build"/>
  <delete quiet="yes" dir="src"/>
  <delete quiet="yes" dir="build"/>
  <mkdir  dir="src/acme"/>
  <mkdir  dir="build/acme"/>

  <touch  file="src/acme/1.xml"        millis="1000"/>
  <touch  file="build/acme/index.html" millis="2000"/>
  <touch  file="src/acme/2.xml"        millis="3000"/>
  <touch  file="build/acme/1.html"     millis="4000"/>

  <target name="t">
    <outofdate
      outputsources="output.sources"
      outputtargets="output.targets"
      verbose="true">
      <sourcefiles>
        <fileset dir="src" includes="**/*.xml"/>
      </sourcefiles>
      <targetfiles path="${build.dir}/index.html"/>
      <mapper type="glob" dir="src"
              from="*.xml" to="${build.dir}/*.html"/>
      <sequential>
        <echo>sources ${output.sources}</echo>
        <echo>targets ${output.targets}</echo>
      </sequential>
    </outofdate>
  </target>
</project>

And the output:
Buildfile: /home/preilly/proj/learning/out/build.xml
Deleting directory /home/preilly/proj/learning/out/src
Deleting directory /home/preilly/proj/learning/out/build
Created dir: /home/preilly/proj/learning/out/src/acme
Created dir: /home/preilly/proj/learning/out/build/acme
Creating /home/preilly/proj/learning/out/src/acme/1.xml
Creating /home/preilly/proj/learning/out/build/acme/index.html
Creating /home/preilly/proj/learning/out/src/acme/2.xml
Creating /home/preilly/proj/learning/out/build/acme/1.html

t:
SourceFile /home/preilly/proj/learning/out/src/acme/1.xml outofdate with
regard to /home/preilly/proj/learning/out/build/index.html
SourceFile /home/preilly/proj/learning/out/src/acme/2.xml outofdate with
regard to /home/preilly/proj/learning/out/build/index.html
SourceFile /home/preilly/proj/learning/out/src/acme/2.xml outofdate with
regard to /home/preilly/proj/learning/out/build/acme/2.html
sources /home/preilly/proj/learning/out/src/acme/2.xml
/home/preilly/proj/learning/out/src/acme/1.xml
targets /home/preilly/proj/learning/out/build/acme/2.html
/home/preilly/proj/learning/out/build/index.html

On Saturday 07 June 2003 03:44, W. Sean Hennessy wrote:
> Getting frustrated after a reasonable effort at implementing
> selectivity using ant-contrib's <outofdate> with <mapper>.
> Given ${src.dir}/*.xml  ==> ${build.dir}/*.html
>
> Three example test scenarios (A.1, A.2, B) exhibit unexpected behavior.
> For each test run have included:
> "Inputs:" corresponding to sourcefiles and targetfiles
> "Results:" output of ant
> "Expected files outofdate:"
>
> Please have a look and point out where my of mapper is incorrect.
>
> Regards,
> Sean
>
> <!-- example OTDMapTst.xml -->
> <project name="OutadateTest" default="outadate.tgt.nm" basedir="..">
>    <property name="src.doc.dir" value="${basedir}/1.doc"/>
>    <property name="build.dir" value="${basedir}/build" />
>    <property name="build.doc.dir" value="${build.dir}/1.doc" />
>    <property name="tools.dir" value="C:/Tools" />
>
>    <!-- required to reference ant-contrib tasks outofdate,foreach et al.
> --> <taskdef resource="net/sf/antcontrib/antcontrib.properties">
>      <classpath>
>        <pathelement
> location="${tools.dir}/ant-contrib-0.3/lib/ant-contrib-0.3.jar" />
>      </classpath>
>    </taskdef>
>
>    <patternset id="srcdoc.ptnset.id">
>       <include name="**/*.xml"/>
>    </patternset>
>
>    <fileset id="srcdoc.fs.id" dir="${src.doc.dir}" >
>       <patternset refid="srcdoc.ptnset.id"/>
>    </fileset>
>
>    <!-- Not working yet  -->
>    <target name="outadate.tgt.nm"
>       description="selective target execution for outofdate src/*xml
> against corresponding build/*html">
>       <outofdate
>                 outputsourcespath="outadate.tgt.outpt.srcpath"
>                 outputsources="outadate.tgt.outpt.srcs"
>                 outputtargets="outadate.tgt.outpt.tgts">
>          <sourcefiles>
>             <fileset refid="srcdoc.fs.id" />
>          </sourcefiles>
>          <!-- BEGIN COMMENT =================================
>              For Tests (A.1 & TEST A.2) COMMENTED OUT
>             group compare against one target
>           END COMMENT ===================================== -->
>          <targetfiles>
>             <pathelement path="${build.dir}/index.html"/>
>          </targetfiles>
>          <!-- BEGIN COMMENT =================================
>            PROBLEM
>                mapper is sposed to be how one
>                associates each sourcefile element with corresponding
output
>                eg. ${src.doc.dir}/filename.xml ==>
> ${build.doc.dir}/filename.html
>                does not seem to work..?!
>           END COMMENT ===================================== -->
>           <mapper type="glob" from="${src.doc.dir}{$file.separator}*.xml"
>
> to="${build.doc.dir}{$file.separator}*.html"/>
>           <sequential>
>             <echo
> message="outadate.tgt.outpt.srcs=${outadate.tgt.outpt.srcs}"/>
>             <echo
> message="outadate.tgt.outpt.tgts=${outadate.tgt.outpt.tgts}"/>
>          </sequential>
>       </outofdate>
>    </target>
> </project>
> <!-- EOF -->
>
>
>
> ======================================================
> The test results:
> ======================================================
> Test A.1  FAIL <!-- <targetfile  -->  Commented Out
> 1. file1.xml date < file1.html date
> 2. file2.xml date <> (no file2.html)
> ========================================
> Inputs:
> 1. 06/06/2003  05:50p 1.doc\file1.xml
> 2. 04/04/2003  11:59a 1.doc\subdir\file2.xml
>
> 06/06/2003  05:34p build\index.html
> 06/06/2003  06:18p build\1.doc\file1.html
>
> Result:
> outadate.tgt.nm:
> [outofdate] 1.doc\file1.xml
> [outofdate] 1.doc\subdir\file2.xml
>
> BUILD SUCCESSFUL
>
> Expected files outofdate:
>  1.doc\subdir\file2.xml  <== No Tgt!
>
> ======================================================
> ======================================================
> Test A.2 FAIL <!-- <targetfile  -->  Commented Out
> 1. file1.xml date > file1.html date
> 2. file2.xml date <> (no file2.html)
> ========================================
> Inputs:
> 06/06/2003  06:30p 1.doc\file1.xml  <<=== NEWER THAN TGT !
> 04/04/2003  11:59a 1.doc\subdir\file2.xml
>
> 06/06/2003  05:34p build\index.html
> 06/06/2003  06:18p build\1.doc\file1.html
>
> Result:
> outadate.tgt.nm:
> [outofdate] 1.doc\file1.xml
> [outofdate] 1.doc\subdir\file2.xml
> BUILD SUCCESSFUL
>
> Expected files outofdate:
>  1.doc\subdir\file2.xml  <== No Tgt
>  1.doc\file1.xml         <== Src newer than map Tgt
>
> ======================================================
> Test B. FAIL <targetfile referencing index.html.
> 1. file1.xml date > file1.html date
> 2. file2.xml date <> (no file2.html)
> ========================================
> Inputs:
> 06/06/2003  06:30p 1.doc\file1.xml
> 04/04/2003  11:59a 1.doc\subdir\file2.xml
>
> 06/06/2003  05:34p build\index.html
> 06/06/2003  06:18p build\1.doc\file1.html
>
> Result:
> outadate.tgt.nm:
> [outofdate] 1.doc\file1.xml
> [outofdate] 1.doc\subdir\file2.xml
> Override ignored for property outadate.tgt.prp
>      [echo]
> outadate.tgt.outpt.srcs=C:\Wrk\WSean\Prj\SCM-Test\1.doc\file1.xml
>      [echo]
> outadate.tgt.outpt.tgts=C:\Wrk\WSean\Prj\SCM-Test\build\index.html
>
> BUILD SUCCESSFUL
> Expected files outofdate:
>  1.doc\subdir\file2.xml  <== No Tgt
>  1.doc\file1.xml         <== Src newer than map Tgt and index.html
> <eom>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message