Loading...

oro-user@jakarta.apache.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

File list - dir list conversion using ant ReplaceRegExp and oro Nicolas Mailhot Mon Jul 12 03:00:26 2004

Hi,

        I'm currently trying to transform a text file containing a list of
absolute filenames into a list of absolute directory names (/a/b/c/d.efg
-> /a/b/c). I'm using the ant ReplaceRegExp task
(http://ant.apache.org/manual/OptionalTasks/replaceregexp.html) with
oro.

        I need the directory names to be unique. Unfortunately since several
files can be in the same directory my first naive attempt resulted in
lots of duplicates :

<project default="test" basedir="." name="regexp">
  <target name="test" description="try to munge the test file">
    <property name="testfile" value="build/core.list"/>
    <property name="outputfile" value="build/coredir.list"/>
    <copy file="${testfile}" tofile="${outputfile}" overwrite="yes"/>
    <!-- Remove lines not starting with / -->
    <replaceregexp file="${outputfile}"
                         match="^[^/](.*)$"
                         replace=""
                         byline="true"/>
    <!-- Remove ending file leafs -->
    <replaceregexp file="${outputfile}"
                         match="/[^/]+$"
                         replace=""
                         byline="true"/>
  </target>
                                                                                
                                              
</project>

        So now I need to remove duplicated lines. I suppose it's possible using
ORO and the replaceregexp task (it seems like the kind of thing it can
do) but I can't even figure were to start. Anyone got a bright idea ?

        Regards,

-- 
Nicolas Mailhot