ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas L Roche <tlro...@us.ibm.com>
Subject Re: how to (usably) include one JAR in another?
Date Thu, 01 Dec 2005 15:57:56 GMT
Tom Roche 11/30/2005 10:35:26 PM:
>> How to make <jar> include the *contents* of another JAR, rather
>> than just that JAR file itself?

<snip>

>> I tried

>> <target name="project.jar" depends="init, compile" 
>>   description="Build project.jar">
>>   <jar 
>>     jarfile="${build.result.folder}/project.jar">
>>     <fileset dir="${compile.outdir}">
>>         <include name="**/*.class"/>
>>     </fileset>
>>     <fileset dir="${lib.dir}">
>>         <include name="**/*.jar"/>
>>     </fileset>
>>     <manifest>
>>       <attribute name="Main-Class" value="foo.bar.project"/>
>>     </manifest>
>>   </jar>
>> </target>

>> but that just creates 

>> $ zipinfo project/build/project.jar 
>> <snip>
>> -rw-r--r--  2.0 unx   180799 b- defN  7-May-05 21:42 
commons-net-1.4.0.jar

>> which is useless @ runtime.

<snip>

>> How best to make the <jar> task include the JAR's classes, not the
>> JAR itself?

Jon Skeet Thu, 01 Dec 2005 08:50:03 GMT
> Have you tried using <zipfileset>? I haven't used it myself, but
> given the documentation, it looks like it's what you're after.

I tried it, but it just copies:

<target name="project.jar" depends="init, compile" 
  description="Build project.jar">
  <jar 
    jarfile="${build.result.folder}/project.jar">
    <fileset dir="${compile.outdir}">
        <include name="**/*.class"/>
    </fileset>
    <zipfileset dir="${lib.dir}">
        <include name="**/*.jar"/>
    </zipfileset>
    <manifest>
       <attribute name="Main-Class" value="foo.bar.project"/>
    </manifest>
  </jar>
</target>

$ zipinfo project/build/project.jar 
Archive:  project/build/project.jar   194207   24
drwxr-xr-x  2.0 unx        0 bx stor  1-Dec-05 10:40 META-INF/
<snip>
-rw-r--r--  2.0 unx   180799 b- defN  7-May-05 21:42 commons-net-1.4.0.jar

What I want is to include its classes, not the JAR itself. Am I
misusing <zipfileset>?

I'm guessing I'll just hafta expand the JAR to temp space and include
from there.

>> Please reply directly to me (as well as the list) if possible, feel
>> free to forward, and TIA.


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


Mime
View raw message