You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Justin Sampson <js...@covia.com> on 2001/03/08 02:20:19 UTC

Error with jar task: A zip file cannot include itself (Ant 1.3)

I've encountered a strange problem with the jar task in Ant 1.3. The problem
does not seem to occur in 1.2.

The problem was during a jar task which was building a jar of a directory in
the directory itself:

    <jar jarfile="foo/foo.jar" basedir="foo" />

Ant seemed to be trying to include the jar file in itself, giving the error
"A zip file cannot include itself". The jar didn't exist before running (and
would have been deleted by a preceding delete task if it did exist). This
error cause the build to fail, with foo/foo.jar having been created with a
manifest and some but not all of the files in foo/.

Anyway, I got around the problem by adding an "excludes" attribute to the
jar task:

    <jar jarfile="foo/foo.jar" basedir="foo" excludes="foo.jar" />

But I'm wondering if this is a bug, and what has changed from 1.2.

Justin Sampson
CoVia Technologies


RE: Error with jar task: A zip file cannot include itself (Ant 1.3)

Posted by Justin Sampson <js...@covia.com>.
Stefan Bodewig <bo...@apache.org> wrote:

> Justin Sampson <js...@covia.com> wrote:
> 
> > The problem was during a jar task which was building a jar of a
> > directory in the directory itself:
> > 
> >     <jar jarfile="foo/foo.jar" basedir="foo" />
> > 
> > Ant seemed to be trying to include the jar file in itself, giving
> > the error "A zip file cannot include itself". The jar didn't exist
> > before running
> 
> But when the directory gets scanned, it does (because the file has
> already been opened for writing).

That's what I figured. Running jar from the command line doesn't complain,
but I just realized it doesn't complain even if the jar file does already
exist, so it must be doing an implicit exclusion.

> > But I'm wondering if this is a bug, and what has changed from 1.2.
> 
> The opposite of a bug. It is a bug of Ant 1.2 to not raise an exception
> if you try to include a zip file into itself.

Okay, thanks!

Justin


Re: Error with jar task: A zip file cannot include itself (Ant 1.3)

Posted by Stefan Bodewig <bo...@apache.org>.
Justin Sampson <js...@covia.com> wrote:

> The problem was during a jar task which was building a jar of a
> directory in the directory itself:
> 
>     <jar jarfile="foo/foo.jar" basedir="foo" />
> 
> Ant seemed to be trying to include the jar file in itself, giving
> the error "A zip file cannot include itself". The jar didn't exist
> before running

But when the directory gets scanned, it does (because the file has
already been opened for writing).

> But I'm wondering if this is a bug, and what has changed from 1.2.

The opposite of a bug. It is a bug of Ant 1.2 to not raise an exception
if you try to include a zip file into itself.

Stefan