You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bill Lynch <bi...@jivesoftware.com> on 2002/03/01 00:39:22 UTC

RE: Add contents of multiple JARs to a Jar?

Diane,

> Have you looked at the optional <jlink> task?

Yep, I tried that but it seems to do the same thing -- that is it merges the
Jars themselves into the target jar, not the *contents* of the jars.

Here's my sample task:

<jlink compress="true" outfile="${jar.dest.dir}/foo.jar">
   <addfiles>
      <pathelement path="${build.lib.merge.dir}/bar1.jar" />
      <pathelement path="${build.lib.merge.dir}/bar2.jar" />
   </addfiles>
</jlink>

I've also tried a few variations on a theme. :) All result in just the jars
included in foo.jar, not the contents.

Is there something else I'm missing?

Thanks in advance,
--Bill


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Add contents of multiple JARs to a Jar?

Posted by Scott Ellsworth <sc...@alodar.com>.
On Thursday, February 28, 2002, at 05:18  PM, Bill Lynch wrote:

>
>> Why not just use the quick and dirty approach?  Make a temp
>> directory, unjar the jars into it and then make a new jar and then 
>> blow away the temp directory?  Even with huge jars it won't really 
>> take that long on a reasonable machine.
>
> That's definitely one way to do it -- I was just looking for something 
> a little more elegant. I think I might modify the zipfileset code to 
> make this work for multiple jars.

I had thought someone was working to make the src attribute of 
zipfileset a fileset itself.  Would that solve your problem?  (It would 
certainly solve one of mine!)

I am looking forward to the next major release with some glee.

(Quoting:

> From: Stefan Bodewig <bo...@apache.org>
> Date: Thu Feb 14, 2002  07:48:51  AM US/Pacific
> Subject: Re: Expanding a list of jars
>
> Basically, [Brian Deitte] adds a nested element that allows you to 
> specify the sources for <zipfileset>s as filesets, thus making <jlink> 
> obsolete.

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Bill Lynch <bi...@jivesoftware.com>.
> Why not just use the quick and dirty approach?  Make a temp
> directory, unjar
> the jars into it and then make a new jar and then blow away the temp
> directory?  Even with huge jars it won't really take that long on a
> reasonable machine.

That's definitely one way to do it -- I was just looking for something a
little more elegant. I think I might modify the zipfileset code to make this
work for multiple jars.

Thanks,
--Bill


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Friek <er...@sumerduckva.com>.
Its been a long day and I already deleted most of this thread so I might be
restating something already suggested, and I may also be stupid by now.

Why not just use the quick and dirty approach?  Make a temp directory, unjar
the jars into it and then make a new jar and then blow away the temp
directory?  Even with huge jars it won't really take that long on a
reasonable machine.

>I've also tried a few variations on a theme. :) All result in just the jars
>included in foo.jar, not the contents.

>Is there something else I'm missing?




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Diane Holt <ho...@yahoo.com>.
--- Diane Holt <ho...@yahoo.com> wrote:
> <addfiles> seems to be for adding files (even jars) and complete
                                                      ^^^as
> entitites rather than putting their contents into the new jar.

(Oops.)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Diane Holt <ho...@yahoo.com>.
--- Bill Lynch <bi...@jivesoftware.com> wrote:
> Yep, it's a bug:
> 
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4584

Oh well -- sorry about that. It all worked for me -- including building
the final jar that uses <jar> w/<zipfileset> on the merged jar and using
compression for the merged jar and all that. I could tvf the final jar
file just fine.

Guess since <jlink> is obsolescent, just work around it till 1.5 comes
out.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Bill Lynch <bi...@jivesoftware.com>.
Yep, it's a bug:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4584

Cheers,
--Bill

> -----Original Message-----
> From: Bill Lynch [mailto:bill@jivesoftware.com]
> Sent: Thursday, February 28, 2002 9:07 PM
> To: Ant Users List
> Subject: RE: Add contents of multiple JARs to a Jar?
> 
> 
> Diane,
> 
> I finally figured it out and may have uncovered a bug in Ant 1.4.1 in the
> process. I got the jlink task to produce a correct jar, but when 
> I included
> that jar as a zipfileset in a jar task, I got the following error:
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Bill Lynch <bi...@jivesoftware.com>.
Diane,

I finally figured it out and may have uncovered a bug in Ant 1.4.1 in the
process. I got the jlink task to produce a correct jar, but when I included
that jar as a zipfileset in a jar task, I got the following error:

build\build.xml:135: Problem creating jar: invalid stored block lengths

I suspected the jar produced from jlink was corrupt, so I tried jar xf
tmp.jar -- here's what I got:

C:\cvs\build\lib\temp>jar xf tmp.jar
java.util.zip.ZipException: invalid stored block lengths
        at
java.util.zip.InflaterInputStream.read(InflaterInputStream.java:139)
        at java.util.zip.ZipInputStream.read(ZipInputStream.java:142)
        at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:93)
        at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:71)
        at sun.tools.jar.Main.extract(Main.java:676)
        at sun.tools.jar.Main.run(Main.java:191)
        at sun.tools.jar.Main.main(Main.java:904)

I tried the jlink task without compresssion it worked just fine. Looks like
there's a bug when producing a jlink'd jar with compression on?

FYI, here's my final target that works:

<target name="jar" depends="compile">
    <mkdir dir="${basedir}/build/lib/temp" />
    <jlink outfile="${basedir}/build/lib/temp/temp.jar" compress="yes">
        <mergefiles>
            <fileset dir="${build.lib.merge.dir}" includes="*.jar" />
        </mergefiles>
    </jlink>
    <jar
        jarfile="${jar.dest.dir}/foo.jar"
        manifest="${resources.dir}/share/manifest.mf"
    >
        <!-- Main .class files: -->
        <fileset dir="${build.dest.dir}" includes="com/foo/**/*.class" />
        <!-- i18n properties files: -->
        <fileset dir="${i18n.dir}" includes="*.properties" />
        <!-- Add in merged jars: -->
        <zipfileset src="${basedir}/build/lib/temp/temp.jar" />
    </jar>
    <delete file="${basedir}/build/lib/temp/temp.jar" />
</target>

Thanks for all your help,
--Bill

> -----Original Message-----
> From: Diane Holt [mailto:holtdl@yahoo.com]
> Sent: Thursday, February 28, 2002 8:33 PM
> To: Ant Users List
> Subject: RE: Add contents of multiple JARs to a Jar?
>
>
> --- Diane Holt <ho...@yahoo.com> wrote:
> > I think you need to use <mergfiles>, don't you?
>
> And for the record, I just tried it and it worked fine -- put the contents
> of the two jars into the output jar.
>
> Diane
>
> =====
> (holtdl@yahoo.com)
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Greetings - Send FREE e-cards for every occasion!
> http://greetings.yahoo.com
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Diane Holt <ho...@yahoo.com>.
--- Diane Holt <ho...@yahoo.com> wrote:
> I think you need to use <mergfiles>, don't you?

And for the record, I just tried it and it worked fine -- put the contents
of the two jars into the output jar.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Add contents of multiple JARs to a Jar?

Posted by Diane Holt <ho...@yahoo.com>.
--- Bill Lynch <bi...@jivesoftware.com> wrote:
> Here's my sample task:
> 
> <jlink compress="true" outfile="${jar.dest.dir}/foo.jar">
>    <addfiles>
>       <pathelement path="${build.lib.merge.dir}/bar1.jar" />
>       <pathelement path="${build.lib.merge.dir}/bar2.jar" />
>    </addfiles>
> </jlink>

I think you need to use <mergfiles>, don't you? That's what the first
example in the doc suggests to me anyway. <addfiles> seems to be for
adding files (even jars) and complete entitites rather than putting their
contents into the new jar.

Diane


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>