ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rhino" <rhi...@sympatico.ca>
Subject Re: How can I set last modified date in html files using ant?
Date Sun, 06 Feb 2005 01:19:26 GMT

----- Original Message ----- 
From: "Luke Lindsay" <luke.lindsay@gmail.com>
To: <user@ant.apache.org>
Sent: Saturday, February 05, 2005 1:36 PM
Subject: 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.
>
The challenge here - for Ant or any human - is to determine when the file
changed so that this information can be written to the file. Presumably, you
want the computer to do this work; otherwise you'd just go through each file
by hand and add a line reporting the date that the file was last updated.

The only place that comes to mind where the last modified date is stored is
in the file attributes kept by the file system. If you could simply
determine that value for each file via an Ant task and then use that task or
some other to write the appropriate line to the file, you'd be all set.

I just had a look at the whole set of core and optional tasks and don't see
anything that actually reports on that last modified date. Now, maybe I just
missed something, in which case I hope someone else on the list will point
that out. On the other hand, if I'm right and there is no such task, you are
probably looking at one of two approaches:
a) use an Exec task to get a directory listing on each directory containing
your HTML files; write that listing to a file and then parse it so that for
each line you get the file name and the last modified date; using the last
modified date, use a task like echo to append a line containing the date to
each file via a loop (or write your own program to do so, rather than using
echo: languages like REXX could do a job like that pretty easily)
b) write your own Ant task to do what you describe.

I can't honestly estimate which of those would be easier/faster for you
since I don't know your abilities. I've heard Ant enthusiasts insist that
its "easy" to write your own Ant task but the time I tried it, I found it
far from intuitive and I've been writing code for 20+ years and Java for 8
years.

Rhino



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


Mime
View raw message