ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: Having a file list
Date Thu, 19 Dec 2002 16:39:30 GMT
I think the (new) task is better. Maybe with support of filesets?
<fileproperties prefix="fileprops">
    <fileset dir="" />
</fileproperties>

fileprops.0.name=Hello
fileprops.0.suffix=txt
fileprops.0.dir=...
fileprops.0.size=100
fileprops.0.lastModifiedDate=1/1/2002   (maybe configurable via
SimpleDateFormat-Pattern ...)

Have fun to write and don´t forget to contribute :-)


Jan Matèrne

-----Ursprüngliche Nachricht-----
Von: Benoit Voisin [mailto:benoit.voisin@ergoidp.dk]
Gesendet am: Donnerstag, 19. Dezember 2002 17:29
An: 'Ant Users List'
Betreff: RE: Having a file list

I quite like this solution. Thanks Jan.

Unfortunately, I also need the file size and date. I could do it in a script
(within ant, or a shell script called by your apply structure), but I think
I would prefer having a fileproperties task, placing in various properties
different info on the file.
for example 

<fileproperties propertybase="file" file="Hello.txt"/>

will generate a serie of properties :
file.size = 100
file.lastModifiedDate = 1/1/2002
...

I could then call this task + an echo into a file from an ant-contrib's
for-each

What do you think ? Or as someone already coded such a task ?


Benoit

-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
Sent: 19. december 2002 17:11
To: ant-user@jakarta.apache.org
Subject: AW: Having a file list


I have a solution with <apply>. Echo the name to a new file.


<project name="directoryListing" default="main" basedir=".">
    <target name="main">

        <echo>
          Lists the the fileset
        </echo>
        <apply executable="cmd.exe" append="true">
            <arg line="/C echo" />
            <fileset dir=".">
                <include name="*.java" />
            </fileset>
        </apply>

        <echo>
          Store the fileset in a text file and show it
        </echo>
        <property name="out" value="dir.out" />
        <delete file="${out}" />
        <apply executable="cmd.exe" append="true" output="${out}">
            <arg line="/C echo" />
            <fileset dir=".">
                <include name="*.java" />
            </fileset>
        </apply>
        <loadfile property="listing" srcFile="${out}"/>
        <echo message="${listing}" />
    </target>
</project>

With some *.txt and some *.java files in my directory the output is:
C:\tmp\anttests\dirListing>ant
Ant-Home:  c:\seu\ant16
Java-Home: c:\seu\jdk14
Buildfile: build.xml

main:
     [echo]
     [echo]           Lists the the fileset
     [echo]
    [apply] C:\tmp\anttests\dirListing\a.java
    [apply] C:\tmp\anttests\dirListing\b.java
    [apply] C:\tmp\anttests\dirListing\c.java
     [echo]
     [echo]           Store the fileset in a text file and show it
     [echo]
     [echo] C:\tmp\anttests\dirListing\a.java
     [echo] C:\tmp\anttests\dirListing\b.java
     [echo] C:\tmp\anttests\dirListing\c.java

BUILD SUCCESSFUL
Total time: 1 second


So I recommend the second solution. :-)


Jan Matèrne

-----Ursprüngliche Nachricht-----
Von: Benoit Voisin [mailto:benoit.voisin@ergoidp.dk]
Gesendet am: Donnerstag, 19. Dezember 2002 16:47
An: 'Ant Users List'
Betreff: Having a file list

Hi all,

I am willing to have a list of files contains in a fileset, basically like a
dir/s will do under windows.
Does anyone know about such a task. It should be too hard to implement, but
if it already exists...

Thanks,
Benoit

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

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

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