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: How can I set last modified date in html files using ant?
Date Tue, 08 Feb 2005 08:11:46 GMT
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



> -----Ursprüngliche Nachricht-----
> Von: Luke Lindsay [mailto:luke.lindsay@gmail.com]
> Gesendet am: Samstag, 5. Februar 2005 19:36
> An: user@ant.apache.org
> Betreff: How can I set last modified date in html files using ant?
> 
> I want set the last modified date in html files from an ant 
> script, so 
> that each file has a line reading, for example:
> 
> "Last modified 04 February 2005" where the date is the date 
> the file was 
> modified, not the date the ant script was run.
> 
> I know I can achieve this using SSI with the following code:
> <!--#config timefmt="%d  %B  %Y" -->
> Last modified <!--#echo var="LAST_MODIFIED" -->
> 
> However, this does not solve my problem since I want to distribute a 
> zipped documentation bundle containing the html files as well as 
> providing access to them over the web.
> 
> I've search google and the mailing list archives but haven't 
> been able 
> to find an answer.
> 
> Any suggestions or pointers would be greatly appreciated.
> 
> Luke Lindsay
> 
> ---------------------------------------------------------------------
> 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