Phil Weighill-Smith wrote:

Won't argue with your comment in general, but Xxx Yyy wrote:



<make a temporary copy of file-A>
<work on temporary copy, growing and changing it>
<when work is complete, replace master copy with temporary>



which seems to be a case where overwrite is appropriate.


touche!

Peter

Phil :n)

On Tue, 2005-03-08 at 16:44, Peter Reilly wrote:



Phil Weighill-Smith wrote:



An alternative, and far more portable work-around is to just use the
overwrite attribute on the second copy task.




I think that this build file is just an example to show the
problem, so this work-around may not be suitable for the real build file.

This is the correct way to show problems,  remove all the
stuff that works and make a build file that just show the bit that fails.


Peter



Phil :n)

On Tue, 2005-03-08 at 16:11, Xxx Yyy wrote:





I looked, but didn't find any discussion on the new granularity
FileUtils.getFileTimestampGranularity.  This is messing up my builds
big-time.

If you are on Windows and you run two COPY operations within two
seconds of each other, the second COPY will be skipped.

<project default="x">
<target name="x">
  <touch file="aaa"/>
  <copy file="aaa" tofile="bbb"/>
  <sleep seconds="1"/>
  <touch file="aaa"/>
  <copy file="aaa" tofile="bbb"/>
</target>
</project>

G:\temp>ant -verbose
Apache Ant version 1.6.2 compiled on July 16 2004
Buildfile: build.xml
Detected Java version: 1.4 in: C:\util\jdk\1.4.2\jre
Detected OS: Windows 2003
parsing buildfile G:\temp\build.xml with URI =
file:///G:/temp/build.xml
Project base dir set to: G:\temp
[property] Loading Environment env.
Build sequence for target `x' is [x]
Complete build sequence is [x, ]

x:
   [copy] Copying 1 file to G:\temp
   [copy] Copying G:\temp\aaa to G:\temp\bbb
  [sleep] sleeping for 1000 milliseconds
   [copy] G:\temp\aaa omitted as G:\temp\bbb is up to date.

BUILD SUCCESSFUL
Total time: 3 seconds
G:\temp>


The problem stems from this code in FileUtils.java.

  public long getFileTimestampGranularity() {
      if (Os.isFamily("dos")) {
          return FAT_FILE_TIMESTAMP_GRANULARITY;
      } else {
          return 0;
      }
  }

This is a very poor test.  I guess there's a limitted granularity of
timestamps on FAT formatted disks.  But this test is assuming that any
drive under DOS or Windows is FAT formatted.

My build files have this pattern:

 <make a temporary copy of file-A>
 <work on temporary copy, growing and changing it>
 <when work is complete, replace master copy with temporary>

If the work takes more than two seconds (or build is run on other os,
unix for example), then the ANT COPY works.  If the work completes in
under two seconds on Windows, ANT COPY fails.

Temporary work-around is to override the granularity attribute on COPY.
But the root cause of the problem (bad test in FileUtils) needs to be
fixed.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33906

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to