You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Misha Koshelev <mi...@gmail.com> on 2010/06/01 19:53:58 UTC

web site example does not work

http://ant.apache.org/manual/Tasks/jar.html

<jar destfile="build/main/checksites.jar">
    <fileset dir="build/main/classes"/>
    <zipfileset includes="**/*.class">
      <fileset dir="lib/main" includes="**/*.jar"/>
    </zipfileset>
    <manifest>
      <attribute name="Main-Class"
            value="com.acme.checksites.Main"/>
    </manifest>
  </jar>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: web site example does not work

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-29, SZEDER Gábor wrote:

> On Tue, Jun 29, 2010 at 01:51:59PM +0200, Stefan Bodewig wrote:
>> On 2010-06-29, Stefan Bodewig wrote:

>>>>>>    <zipfileset includes="**/*.class">
>>>>>>      <fileset dir="lib/main" includes="**/*.jar"/>
>>>>>>    </zipfileset>

>>> It looks as if the example wanted to use zipgroupfileset instead of
>>> zipfileset.

>> No, that wouldn't work either.  <zipgroupfileset> cannot filter its
>> contents.

>> <restrict>
>>   <name name="**/*.class"/>
>>   <archives>
>>     <zips>
>>       <fileset dir="lib/main" includes="**/*.jar"/>
>>     </zips>
>>   </archives>
>> </restrict>

>> is a correct way to do what the example promises,

> Yes, this works here, too.

So I provided at least one correct answer ;-)

>> as would be

>> <restrict>
>>   <name name="**/*.class"/>
>>   <zipgroupfileset dir="lib/main" includes="**/*.jar"/>
>> </restrict>

> But this does not work, because "restrict doesn't support the nested
> "zipgroupfileset" element."

This is because zipgroupfileset is not a standalone resource collection
but only supported as nested element of the zip task.  I forgot about
that, but this is the reason we added the more generic archives resource
collection in 1.8.0.

> Interesting sidenote:
> Your first variant takes "Total time: 19 seconds", while the following
> snipplet only takes "Total time: 3 seconds" on the same set of files
> to produce a jar file with the same contents.

> <unjar dest="${unjardir}" overwrite="false">
>         <fileset dir="${lib}" includes="**/*.jar"/>
> </unjar>
> <jar jarfile="${testjar}">
>         <fileset dir="${unjardir}" includes="**/*.class"/>
> </jar>

Whenever we deal with reading from zips in a resource collection - be it
for <zipfileset> or <archives> - we open the archive, parse the central
directory, position at the entry we want to extract, hand out the
resource and close the archive.  Yes, this is horrribly inefficient but
so far we don't have any other good solution that ensures that we'll
close the archive we read from properly.

<tarfileset> or the <tar> child of <archives> doesn't exhibit the same
problem (neither do the cpio and ar variants in the unreleased compress
Antlib) because the tar format can properly be read from in a streaming
way.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: web site example does not work

Posted by Peter Reilly <pe...@gmail.com>.
2010/6/29 SZEDER Gábor <sz...@ira.uka.de>:
> Hi Stefan,
>
> thanks for your reply.
>
> On Tue, Jun 29, 2010 at 01:51:59PM +0200, Stefan Bodewig wrote:
>> On 2010-06-29, Stefan Bodewig wrote:
>>
>> >>>>    <zipfileset includes="**/*.class">
>> >>>>      <fileset dir="lib/main" includes="**/*.jar"/>
>> >>>>    </zipfileset>
>>
>> > It looks as if the example wanted to use zipgroupfileset instead of
>> > zipfileset.
>>
>> No, that wouldn't work either.  <zipgroupfileset> cannot filter its
>> contents.
>>
>> <restrict>
>>   <name name="**/*.class"/>
>>   <archives>
>>     <zips>
>>       <fileset dir="lib/main" includes="**/*.jar"/>
>>     </zips>
>>   </archives>
>> </restrict>

Ah, Yes, my test code only had one jar file in lib/main!

>>
>> is a correct way to do what the example promises,
>
> Yes, this works here, too.
>
>> as would be
>>
>> <restrict>
>>   <name name="**/*.class"/>
>>   <zipgroupfileset dir="lib/main" includes="**/*.jar"/>
>> </restrict>
>
> But this does not work, because "restrict doesn't support the nested
> "zipgroupfileset" element."
>
>
> Interesting sidenote:
> Your first variant takes "Total time: 19 seconds", while the following
> snipplet only takes "Total time: 3 seconds" on the same set of files
> to produce a jar file with the same contents.
Wow, that is slow!,

Peter

>
> <unjar dest="${unjardir}" overwrite="false">
>        <fileset dir="${lib}" includes="**/*.jar"/>
> </unjar>
> <jar jarfile="${testjar}">
>        <fileset dir="${unjardir}" includes="**/*.class"/>
> </jar>
>
>
> Best,
> Gábor
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: web site example does not work

Posted by SZEDER Gábor <sz...@ira.uka.de>.
Hi Stefan,

thanks for your reply.

On Tue, Jun 29, 2010 at 01:51:59PM +0200, Stefan Bodewig wrote:
> On 2010-06-29, Stefan Bodewig wrote:
> 
> >>>>    <zipfileset includes="**/*.class">
> >>>>      <fileset dir="lib/main" includes="**/*.jar"/>
> >>>>    </zipfileset>
> 
> > It looks as if the example wanted to use zipgroupfileset instead of
> > zipfileset.
> 
> No, that wouldn't work either.  <zipgroupfileset> cannot filter its
> contents.
> 
> <restrict>
>   <name name="**/*.class"/>
>   <archives>
>     <zips>
>       <fileset dir="lib/main" includes="**/*.jar"/>
>     </zips>
>   </archives>
> </restrict>
> 
> is a correct way to do what the example promises,

Yes, this works here, too.

> as would be 
> 
> <restrict>
>   <name name="**/*.class"/>
>   <zipgroupfileset dir="lib/main" includes="**/*.jar"/>
> </restrict>

But this does not work, because "restrict doesn't support the nested
"zipgroupfileset" element."


Interesting sidenote:
Your first variant takes "Total time: 19 seconds", while the following
snipplet only takes "Total time: 3 seconds" on the same set of files
to produce a jar file with the same contents.

<unjar dest="${unjardir}" overwrite="false">
        <fileset dir="${lib}" includes="**/*.jar"/>
</unjar>
<jar jarfile="${testjar}">
        <fileset dir="${unjardir}" includes="**/*.class"/>
</jar>


Best,
Gábor


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: web site example does not work

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-29, Stefan Bodewig wrote:

>>>>    <zipfileset includes="**/*.class">
>>>>      <fileset dir="lib/main" includes="**/*.jar"/>
>>>>    </zipfileset>

> It looks as if the example wanted to use zipgroupfileset instead of
> zipfileset.

No, that wouldn't work either.  <zipgroupfileset> cannot filter its
contents.

<restrict>
  <name name="**/*.class"/>
  <archives>
    <zips>
      <fileset dir="lib/main" includes="**/*.jar"/>
    </zips>
  </archives>
</restrict>

is a correct way to do what the example promises, as would be 

<restrict>
  <name name="**/*.class"/>
  <zipgroupfileset dir="lib/main" includes="**/*.jar"/>
</restrict>

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: web site example does not work

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-28, SZEDER Gábor wrote:

> Hi,


> On Sun, Jun 13, 2010 at 04:26:51PM +0100, Peter Reilly wrote:
>> how is it failing?

>>> <jar destfile="build/main/checksites.jar">
>>>    <fileset dir="build/main/classes"/>
>>>    <zipfileset includes="**/*.class">
>>>      <fileset dir="lib/main" includes="**/*.jar"/>
>>>    </zipfileset>
>>>    <manifest>
>>>      <attribute name="Main-Class"
>>>            value="com.acme.checksites.Main"/>
>>>    </manifest>
>>>  </jar>

> .../build.xml:3: only single argument resource collections are supported as archives

The nested resource collection of a <zipfileset> specifies the single
archive to read from.

>> it works for me with ant 1.8.0.

> fails here with both 1.8.0 and 1.8.1.

The code above will work if there is only a single jar under lib/main
but fail if there is more than one.

It looks as if the example wanted to use zipgroupfileset instead of
zipfileset.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: web site example does not work

Posted by SZEDER Gábor <sz...@ira.uka.de>.
Hi,


On Sun, Jun 13, 2010 at 04:26:51PM +0100, Peter Reilly wrote:
> how is it failing?

.../build.xml:3: only single argument resource collections are supported as archives

> what version of ant are you using ?
> 
> it works for me with ant 1.8.0.

fails here with both 1.8.0 and 1.8.1.


Best,
Gábor


> On Tue, Jun 1, 2010 at 6:53 PM, Misha Koshelev <mi...@gmail.com> wrote:
> > http://ant.apache.org/manual/Tasks/jar.html
> >
> > <jar destfile="build/main/checksites.jar">
> >    <fileset dir="build/main/classes"/>
> >    <zipfileset includes="**/*.class">
> >      <fileset dir="lib/main" includes="**/*.jar"/>
> >    </zipfileset>
> >    <manifest>
> >      <attribute name="Main-Class"
> >            value="com.acme.checksites.Main"/>
> >    </manifest>
> >  </jar>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: web site example does not work

Posted by Peter Reilly <pe...@gmail.com>.
how is it failing?

what version of ant are you using ?

it works for me with ant 1.8.0.

Peter

On Tue, Jun 1, 2010 at 6:53 PM, Misha Koshelev <mi...@gmail.com> wrote:
> http://ant.apache.org/manual/Tasks/jar.html
>
> <jar destfile="build/main/checksites.jar">
>    <fileset dir="build/main/classes"/>
>    <zipfileset includes="**/*.class">
>      <fileset dir="lib/main" includes="**/*.jar"/>
>    </zipfileset>
>    <manifest>
>      <attribute name="Main-Class"
>            value="com.acme.checksites.Main"/>
>    </manifest>
>  </jar>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org