When I use a touch task with a mapper <touch mkdirs="true" verbose="${TALK}" > <fileset dir="${orig-dir}"/> <globmapper from="*" to="${shadow-dir}/*"/> </touch> Produces empty files that are OLDER than sources. After running this task and using ls --time-style=full-iso, I get the following timestamp for source: 2009-09-30 07:44:26.290894100 -0400 And this timestamp for target 2009-09-30 07:44:26.290000000 -0400 Notice that target now is older than source. This breaks <ant-contrib:outofdate> task later on.
Ant uses the lastModified and setLastModified methods in java.io.File http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html which doesn't allow a granularity smaller than millisecond. I don't understand why outofdate seems to be rounding up here but as far as I can see there isn't anything touch could do differently as it set the last modified time to the one read from the source file. CANTFIX rather than WONTFIX.
(In reply to comment #1) > Ant uses the lastModified and setLastModified methods in java.io.File > http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html which doesn't allow a > granularity smaller than millisecond. > > I don't understand why outofdate seems to be rounding up here but as far as I > can see there isn't anything touch could do differently as it set the last > modified time to the one read from the source file. > > CANTFIX rather than WONTFIX. How about setting it to newFile.setLastModified( origFile.lastModified() + 1 ) This will definitely round it in the right direction. Plus it would probably integrate better with the tools external to ant (e.g. make), that could have used the newly created file.
Is it possible to add "roundup" attribute to Touch task, similar in concept to one in Zip task. Then if the attribute is set, you can do newFile.setLastModified( origFile.lastModified() + 1 ) as proposed in Comment 2