ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Sorting directory entries
Date Tue, 11 May 2004 14:17:09 GMT
> From: Johan Vromans CPWR [mailto:johan.vromans@nl.compuware.com]
> 
>      <subant inheritAll="true" failOnError="false">
>        <fileset dir="." includes="tests/*.xml"/>
>      </subant>
> 
> Is it possible to control the execution order without having to use
> explicit filelists?

Well, you can't have it all. Either you specify an explicit list (using a
<buildpath>, not a <filelist>), or order doesn't matter.

That said, there are solutions ;-) I'd argue you should need any of them,
but one never knows, every situation's different...

If I was in your shoes, I would have two approaches:

1) Use my <bm:subant> which takes an optional BuildPathResolver,
   and implement a custom resolver for your particular case.

2) Use another experiment I made last year to control the order
   (and number) of files returned by a fileset. An example is
   shown below.

I posted the full code of (1) a few months back, in BugZilla.
I don't recall the bug id. It's not a single class, so it's
a bit more difficult to share.

About (2), it's a single class (a HACK really) which doesn't
appear to depend on my other stuff, so I could easily share it.
It has 3 built-in sorters (last-modified, forward-alpha,
and reverse-alpha), and 2 filters (head and tail). Because it's
a HACK, the fileset must be defined inside the <filesetdecorator>
task, and refid'd somewhere else (like <subant>).

Let me know. --DD

C:\oss\org_apache\antx>P:\com_lgc\cycle9\buildtools\ant\bin\ant -emacs -f
fileset-decorator1.6.xml
Buildfile: fileset-decorator1.6.xml
FILES-random = P:\com_lgc\cycle9\buildtools\ant\bin\ant
               P:\com_lgc\cycle9\buildtools\ant\bin\ant.bat
               P:\com_lgc\cycle9\buildtools\ant\bin\ant.cmd
               P:\com_lgc\cycle9\buildtools\ant\bin\antRun
               P:\com_lgc\cycle9\buildtools\ant\bin\antRun.bat
               P:\com_lgc\cycle9\buildtools\ant\bin\antRun.pl
               P:\com_lgc\cycle9\buildtools\ant\bin\antenv.cmd
               P:\com_lgc\cycle9\buildtools\ant\bin\complete-ant-cmd.pl
               P:\com_lgc\cycle9\buildtools\ant\bin\envset.cmd
               P:\com_lgc\cycle9\buildtools\ant\bin\lcp.bat
               P:\com_lgc\cycle9\buildtools\ant\bin\runant.pl
               P:\com_lgc\cycle9\buildtools\ant\bin\runant.py
               P:\com_lgc\cycle9\buildtools\ant\bin\runrc.cmd
               P:\com_lgc\cycle9\buildtools\ant\etc\ant-bootstrap.jar
               P:\com_lgc\cycle9\buildtools\ant\etc\changelog.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\coverage-frames.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\jdepend-frames.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\jdepend.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\junit-frames.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\junit-noframes.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\log.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\maudit-frames.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\mmetrics-frames.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\tagdiff.xsl
FILES-sorted = P:\com_lgc\cycle9\buildtools\ant\bin\antRun
               P:\com_lgc\cycle9\buildtools\ant\bin\complete-ant-cmd.pl
               P:\com_lgc\cycle9\buildtools\ant\bin\antRun.bat
               P:\com_lgc\cycle9\buildtools\ant\bin\lcp.bat
               P:\com_lgc\cycle9\buildtools\ant\etc\changelog.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\jdepend.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\junit-noframes.xsl
               P:\com_lgc\cycle9\buildtools\ant\etc\tagdiff.xsl
               P:\com_lgc\cycle9\buildtools\ant\bin\ant
               P:\com_lgc\cycle9\buildtools\ant\bin\ant.bat

BUILD SUCCESSFUL
Total time: 2 seconds
C:\oss\org_apache\antx>C:\oss\org_apache\antx>type fileset-decorator1.6.xml
<?xml version="1.0"?>

<!-- ANT build file to test a specific feature or bug of ANT.
     Dominique Devienne <ddevienne@lgc.com>         Sep 2003
  -->
<project name="fileset-decorator"
         xmlns:bm="antlib:com.lgc.buildmagic">

  <description>
    Sorts or filters the files of a fileset using custom task!
  </description>

  <!-- Simulate user-supplied FileSets -->
  <fileset id="FILES-random" dir="${ant.home}" includes="etc/*, bin/*" />

  <!-- Print fileset before -->
  <property name="sep" value="${line.separator}               " />
  <pathconvert property="random-files" refid="FILES-random" pathsep="${sep}"
/>
  <echo message="FILES-random = ${random-files}" />

  <!-- Sort by last-modified timestamp and keep 10 first only -->
  <bm:filesetdecorator>
    <bm:fileset id="FILES-sorted" dir="${ant.home}"
                includes="etc/*, bin/*" />
    <bm:sorter type="last-modified" />
    <bm:filter type="head" />
  </bm:filesetdecorator>

  <!-- Print fileset after -->
  <pathconvert property="sorted-files" refid="FILES-sorted" pathsep="${sep}"
/>
  <echo message="FILES-sorted = ${sorted-files}" />

</project>

C:\oss\org_apache\antx>

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


Mime
View raw message