You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2008/09/26 21:56:48 UTC

DO NOT REPLY [Bug 45902] New: Up-to-date checks for JARs broken due to comparison of dir timestamps

https://issues.apache.org/bugzilla/show_bug.cgi?id=45902

           Summary: Up-to-date checks for JARs broken due to comparison of
                    dir timestamps
           Product: Ant
           Version: 1.7.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: jglick@netbeans.org


If you follow the (rather complex) instructions in

http://www.netbeans.org/nonav/issues/show_bug.cgi?id=142466

you can (sometimes) reproduce a regression in Ant 1.7.1;
samples/admin/target/useradmin-shared.jar is recreated during incremental
builds. The log for this <jar> task says

....
net/java omitted as
/tmp/genesis-3.1/samples/admin/target/useradmin-shared.jar:net/java/ is up to
date.
net/java/dev omitted as
/tmp/genesis-3.1/samples/admin/target/useradmin-shared.jar:net/java/dev/ is up
to date.
net/java/dev/genesis omitted as
/tmp/genesis-3.1/samples/admin/target/useradmin-shared.jar:net/java/dev/genesis/
is up to date.
....
net omitted as /tmp/genesis-3.1/samples/admin/target/useradmin-shared.jar:net/
is up to date.
net/java omitted as
/tmp/genesis-3.1/samples/admin/target/useradmin-shared.jar:net/java/ is up to
date.
net/java/dev omitted as
/tmp/genesis-3.1/samples/admin/target/useradmin-shared.jar:net/java/dev/ is up
to date.
net/java/dev/genesis omitted as
/tmp/genesis-3.1/samples/admin/target/useradmin-shared.jar:net/java/dev/genesis/
is up to date.
....
net added as net/ is outdated.
net/java added as net/java/ is outdated.
net/java/dev added as net/java/dev/ is outdated.
net/java/dev/genesis added as net/java/dev/genesis/ is outdated.
....

The problem occurs only when directories are added to the JAR file.

Uncommenting

  if (target.isDirectory()) return false;

from ResourceUtils.selectOutOfDateSources' ResourceSelector.isSelected impl
causes the issue not to appear; the problem seems to relate to a ZipResource
".../admin/target/useradmin-shared.jar:net/" always being OOD relative to a
FileResource ".../admin/modules/shared/target/hibernate/net".

Of course uncommenting that line would regress performance of many tasks. I'm
not sure why we are even checking timestamps on ZIP folders; surely these do
not matter to begin with? There is

  if (doFilesonly) resources = selectFileResources(resources);

in Zip.java but I do not understand why this is conditional; seems to me that
this should be run even if !doFilesonly. Making this unconditional might fix
the issue for me; I am not sure because now I can no longer reproduce the
original problem (seems to come and go).

The build script is too complex for me to follow. The problem may be ultimately
due to some user error in the script. But I think I am out of my depth with the
new resource collection code which I can barely follow.


BTW (probably unrelated to this bug): peterreilly changed my code in
SelectorUtils.isOutOfDate to create a sourceExists local variable - but it is
unused! Perhaps there is a missing

  if (!sourceExists) return false;

?


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902





--- Comment #4 from Stefan Bodewig <bo...@apache.org>  2009-01-28 01:42:38 PST ---
http://marc.info/?l=ant-dev&m=123313502805580&w=2


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Ivan Todoroski <gr...@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |grnch@gmx.net




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902





--- Comment #1 from Jesse Glick <jg...@netbeans.org>  2009-01-27 16:31:33 PST ---
I think I have a reproducible test case finally, after seeing it happen to me
on my own build script:

<project name="testant45902" default="x" basedir=".">
    <target name="x">
        <delete dir="demo"/>
        <mkdir dir="demo/src/p"/>
        <touch file="demo/src/p/X.java"/>
        <touch file="demo/src/p/x.properties"/>
        <mkdir dir="demo/build"/>
        <copy todir="demo/build">
            <fileset dir="demo/src" includes="**/*.java"/>
        </copy>
        <sleep seconds="1"/>
        <echo>(first JAR task)</echo>
        <jar jarfile="demo/jar.jar">
            <fileset dir="demo/build"/>
            <fileset dir="demo/src" excludes="**/*.java"/>
        </jar>
        <sleep seconds="1"/>
        <touch file="demo/src/p/y.properties"/>
        <sleep seconds="1"/>
        <delete file="demo/src/p/y.properties"/>
        <echo>(second JAR task)</echo>
        <jar jarfile="demo/jar.jar">
            <fileset dir="demo/build"/>
            <fileset dir="demo/src" excludes="**/*.java"/>
        </jar>
        <sleep seconds="1"/>
        <echo>(third JAR task)</echo>
        <jar jarfile="demo/jar.jar">
            <fileset dir="demo/build"/>
            <fileset dir="demo/src" excludes="**/*.java"/>
        </jar>
        <echo>(fourth JAR task)</echo>
        <jar jarfile="demo/jar.jar">
            <fileset dir="demo/build"/>
            <fileset dir="demo/src" excludes="**/*.java"/>
        </jar>
    </target>
</project>

tmp$ /space/ant170/bin/ant -f testant45902.xml 
Buildfile: testant45902.xml

x:
Deleting directory /tmp/demo
Created dir: /tmp/demo/src/p
Creating /tmp/demo/src/p/X.java
Creating /tmp/demo/src/p/x.properties
Created dir: /tmp/demo/build
Copying 1 file to /tmp/demo/build
(first JAR task)
Building jar: /tmp/demo/jar.jar
Creating /tmp/demo/src/p/y.properties
Deleting: /tmp/demo/src/p/y.properties
(second JAR task)
(third JAR task)
(fourth JAR task)

BUILD SUCCESSFUL
Total time: 4 seconds

tmp$ /space/ant171/bin/ant -f testant45902.xml 
Buildfile: testant45902.xml

testant45902.x:
Deleting directory /tmp/demo
Created dir: /tmp/demo/src/p
Creating /tmp/demo/src/p/X.java
Creating /tmp/demo/src/p/x.properties
Created dir: /tmp/demo/build
Copying 1 file to /tmp/demo/build
(first JAR task)
Building jar: /tmp/demo/jar.jar
Creating /tmp/demo/src/p/y.properties
Deleting: /tmp/demo/src/p/y.properties
(second JAR task)
Building jar: /tmp/demo/jar.jar
(third JAR task)
Building jar: /tmp/demo/jar.jar
(fourth JAR task)
Building jar: /tmp/demo/jar.jar

BUILD SUCCESSFUL
Total time: 4 seconds

When running with -v under 1.7.1 you can see that <jar> is getting confused by
directory timestamps:

....
(second JAR task)
p omitted as /tmp/demo/jar.jar:p/ is up to date.
p/X.java omitted as /tmp/demo/jar.jar:p/X.java is up to date.
p added as p/ is outdated.
p/x.properties omitted as /tmp/demo/jar.jar:p/x.properties is up to date.
Building jar: /tmp/demo/jar.jar
....

If I take by-the-second timestamp info in the demo dir after completion, I see

19:26:47 build
19:26:47 build/p
19:26:47 build/p/X.java
19:26:51 jar.jar
19:26:47 src
19:26:50 src/p
19:26:47 src/p/X.java
19:26:47 src/p/x.properties

and inside jar.jar:

19:26:52 META-INF/
19:26:50 META-INF/MANIFEST.MF
19:26:48 p/
19:26:48 p/X.java
19:26:48 p/x.properties


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ken.corbin@hp.com




--- Comment #5 from Stefan Bodewig <bo...@apache.org>  2009-01-29 07:03:22 PST ---
*** Bug 29683 has been marked as a duplicate of this bug. ***


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




--- Comment #3 from Stefan Bodewig <bo...@apache.org>  2009-01-28 01:23:06 PST ---
I have a few issues that I'm going to raise on the dev list.

I've created an AntUnit test from your testcase: svn revision 738412 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=738412 )


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Jay Berkenbilt <ej...@ql.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ejb@ql.org




--- Comment #6 from Jay Berkenbilt <ej...@ql.org>  2009-05-25 13:52:27 PST ---
For what it's worth, I think I have a simpler way to reproduce this.

Create a/dir/1 and b/dir/2

Then run ant twice with this build.xml:

<project default="default">
 <target name="default">
  <jar destfile="a.jar">
   <fileset dir="a"/>
   <fileset dir="b"/>
  </jar>
 </target>
</project>

With 1.7.0, the second ant does correctly does nothing.  Verbose output:

      [jar] dir omitted as /home/jberkenb/tmp/z/a.jar:dir/ is up to date.
      [jar] dir/1 omitted as /home/jberkenb/tmp/z/a.jar:dir/1 is up to date.
      [jar] dir omitted as /home/jberkenb/tmp/z/a.jar:dir/ is up to date.
      [jar] dir/2 omitted as /home/jberkenb/tmp/z/a.jar:dir/2 is up to date.

With 1.7.1, the second ant rebuilds:

      [jar] dir omitted as /home/jberkenb/tmp/z/a.jar:dir/ is up to date.
      [jar] dir/1 omitted as /home/jberkenb/tmp/z/a.jar:dir/1 is up to date.
      [jar] dir added as dir/ is outdated.
      [jar] dir/2 omitted as /home/jberkenb/tmp/z/a.jar:dir/2 is up to date.
      [jar] Building jar: /home/jberkenb/tmp/z/a.jar
      [jar] adding directory META-INF/
      [jar] adding entry META-INF/MANIFEST.MF
      [jar] adding directory dir/
      [jar] adding entry dir/1
      [jar] adding entry dir/2

Notice that the second time "dir" is checked, ant 1.7.1 just says that "dir/"
is outdated, while ant 1.7.0 reports that "/home/jberkenb/tmp/z/a.jar:dir/" is
up to date.

My current directory is /home/jberkenb/tmp/z as I run this....

I'm not sure whether this is a manifestation of the same bug, but it would be
great to see if it works with the fix applied to correct this bug.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Jesse Glick <jg...@netbeans.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |1.8.0




--- Comment #2 from Jesse Glick <jg...@netbeans.org>  2009-01-27 17:17:41 PST ---
I think fixed in SVN rev 738330. Reviews welcome.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Michel Graciano <mi...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |michel.graciano@gmail.com




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Emmanuel Bourg <eb...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebourg@apache.org




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902





--- Comment #7 from Jay Berkenbilt <ej...@ql.org>  2009-05-25 13:56:11 PST ---
Most likely you can just disregard my comment.  I see the posted test case is
doing the same thing with the multiple jar tasks and creation of
files/directories called from the test case.  My observation is that the
problem happens when the same directory is added from two different filesets. 
I'm not sure that explicit observation is of any use or not.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902





--- Comment #8 from Stefan Bodewig <bo...@apache.org>  2009-07-15 03:32:57 PST ---
svn revision 794215 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=794215 ) should fix the dir timestamp issue for all except for the
"same directory comes from multiple sources" case - which we have in our
AntUnit test so it still fails.

The problem with directories from multiple sources is that Ant only adds the
first directory encountered - and now preserves that timestamp - but may later
find there are more recent directories in other places.

The way I intend to work on this is to perform some global sort on all
directory resources making sure they get added in the right order and only the
most recent timestamps get recorded - this is going to take some additional
plumbing.

The same issue could come up with file timestamps but is less likely o happen
since archives with multiple entries for the same file are less common (and you
get a warning message in verbose mode anyway).

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45902] Up-to-date checks for JARs broken due to comparison of dir timestamps

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45902


Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED




--- Comment #9 from Stefan Bodewig <bo...@apache.org>  2009-07-15 06:11:36 PST ---
After coding the logic described in comment #8 I realized it was complicating
the task even more, so I settled with a more humble goal.

svn revision 794255 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=794255 ) (which will be followed by an extract method refactoring)
will compare file timestamps and recreate the archive if new directories have
been added.  It will record a directories timestamp but not compare it with the
dir timestamps when updating an archive.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.