I am writing a manifest.xml file during an Ant build for an OpenCMS project.
I need to be able to pull up a file’s create date, and last modified date on a file. (Although the current process is giving each file a timestamp of Wed, 31 Dec 1969 19:00:00 EST anyway — at least on Windows machines when they run the build.)
Is there a way I can pull up the creation date timestamp of a file in Ant? I’m using standard Ant tasks and Ant-Contrib tasks.
It depends on your OS, f.e. Unix doesn’t store the file creation time, see details here
Two possible solutions :
Solution 1, works on Windows only with Java >= 6, no addons needed
Solution 2, needs Java 7 and groovy-all-x.x.x.jar (contained in groovy binary release)
Adjust the SimpleDateFormat to your liking.
On Unix filesystems when asking for creationtime you’ll get the last modification time.
I tried also using the builtin javascript engine, but i got errors like :
IMO, for simple things using javascript
<script language="javascript">is sufficient, but if you need to import java packages etc. .. it’s a PITA. Groovy simply works.