ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: <copy> & <filelist>
Date Fri, 11 Jul 2003 06:48:50 GMT
AFAIK the only way is using AntContribs <foreach> with the <copy> as target.
Oh - no: another one: using <script> and iterating over the list ...



<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="test" basedir="." default="main">
    <target name="main">
        <!-- Properties for storing source- and dest-value -->
        <property name="src.dir"  value="src"/>
        <property name="dest.dir" value="dest"/>

        <!-- Create the directory -->
        <delete dir="${dest.dir}"/>
        <mkdir dir="${dest.dir}"/>

        <!-- Specify the filelist with an 'id' attribute -->
        <filelist id="fl" dir="${src.dir}" files="1.txt,2.txt,4.txt"/>

        <!-- Do the copy -->
        <script language="javascript"> <![CDATA[
            // getting a String[]; 'fl' is defined by its id-attribute;
            // 'project' is an implied object inside 'script' task
            files = fl.getFiles(project);

            // get the property
            dest = project.getProperty("dest.dir");

            // source directory specified by filelist
            src = fl.getDir(project);

            // create a copy task
            copy = project.createTask("copy");
            copy.setTodir(new java.io.File(dest));


            // iterate over the files
            for(i=0; i<files.length; i++) {
                copy.setFile(new java.io.File(src, files[i]));
                copy.perform();
            }
        ]]></script>
    </target>
</project>



Jan

> -----Original Message-----
> From: Dan Guerrero [mailto:Dan.Guerrero@tvguide.com]
> Sent: Thursday, July 10, 2003 5:39 PM
> To: 'Ant Users List'
> Subject: <copy> & <filelist>
> 
> 
> I apologize if this question has been asked and answered 
> elsewhere but I am
> trying to build a specific list of files to be copied using 
> <filelist> and
> then trying to copy that list into a specific directory.  
> However, <copy>
> does not support nested <filelist>, only <fileset>.
> 
> Is there any way I can copy a specific list of files from one 
> directory into
> another?
> 
> Thank you
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message