[EMAIL PROTECTED] wrote:
Hhmm - not easy ... 1) "iterate" over a fileset 2) check the date for each time 3) modify the files content hmm - maybe (pseudo code):
01: <for param="file"> 02: <fileset .../> 03: <sequential> 04: <script> 05: importClass(Package.java.io.File); 06: f = new File("@{file}"); 07: project.setProperty("date", f.lastModDate() ); 08: </script> 09: <replaceregexp file="@{file}" match="..." replace="${date}"/> 10: </sequential> 11: </for>
Line 7 is not "Ant-conform" - it overrides an existing property (usually you should use the setNewProperty() method). But this is a hack :) In Line 7 you also have to search for the right method in File :-)
And ... no garantue :-O
Jan
Thanks for the suggestion, it worked using the code below.
<taskdef resource="net/sf/antcontrib/antlib.xml" /> <for param="file"> <fileset dir="${doc}/docs"> <include name="**/*.html" /> <include name="**/*.htm" /> </fileset>
<sequential> <script language="jython"> <![CDATA[ from java.io import File from java.util import Date from java.text import SimpleDateFormat file = File("@{file}")
if file.lastModified() == 0: project.setProperty("date", "unknown" ) else: date = Date(file.lastModified()) sdf = SimpleDateFormat("dd MMM yyyy") project.setProperty("date", sdf.format(date) ) ]]> </script> <echo>@{file} ${date}</echo> <replace file="@{file}" token="@lastModified@" value="${date}"/> </sequential>
</for>
Luke
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]