ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <sflo...@nc.rr.com>
Subject Re: Pull multiple .class files from multiple .jars into one .jar
Date Tue, 01 Mar 2011 14:30:43 GMT
Sorry, my example is slightly wrong...

I mean:

Jar 1
-----
Foo.class (inherits Bar.class)
Bar.class

Jar 2
-----
Alpha.class (inherits Beta.class)
Beta.class

New Jar
-------
Foo.class
Alpha.class



On Tue, 1 Mar 2011, Scot P. Floess wrote:

>
> You can certainly unjar all the jars...apply your patternset for those class 
> files and jar those into the new jar...
>
> However, should you want to use this jar file by itself (meaning without the 
> original jar files), you may find yourself getting 
> ClassNotFoundException's...
>
> For example, assume you have the following:
>
> Jar 1
> -----
> Foo.class (inherits Bar.class)
>
> Jar 2
> -----
> Alpha.class (inherits Beta.class)
>
> New Jar
> -------
> Foo.class
> Alpha.class
>
>
> In the above scenario, the new jar is missing both Bar.class and Beta.class - 
> therefore you will not be able to instantiate Foo nor Alpha...
>
>
> Regardless, look at the jar and unjar tasks...
>
> Hope that helps...
>
>
>
> On Tue, 1 Mar 2011, Vilius Vaivada wrote:
>
>>  Hi all,
>>
>>  I'm new to ant, so I might be missing something fairly obvious. My
>>  problem:
>>  * I have a lib/ directory full of .jar files
>>  * I have 2 patternsets for some .class files that I want to put into two
>>  new jar files.
>>
>>  After a bit of googling I have this:
>>
>>  <target name="foo">
>>   <foreach target="bar" param="jar">
>>     <path>
>>       <fileset dir="path" includes=" *.jar"/>
>>     </path>
>>  </foreach>
>>  </target>
>>
>>  <target name="bar">
>>   <jar destfile="foo.jar">
>>     <zipfileset src="${jar}">
>>       <patternset refid="pattern_client"/>
>>       <patternset refid="pattern_ear"/>
>>     </zipfileset>
>>  </jar>
>>  </target>
>>
>>  Obviously, it doesn't quite work (and is ugly already). I could try to
>>  collect the .class files (zipfilesets) and jar them up afterwards
>>  (how?). But most probably there's a much better way to do this in the
>>  first place - please advise.
>>
>>  Thank you
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>  For additional commands, e-mail: user-help@ant.apache.org
>> 
>> 
>
>

-- 
Scot P. Floess             RHCT  (Certificate Number 605010084735240)
Chief Architect FlossWare  http://sourceforge.net/projects/flossware
                            http://flossware.sourceforge.net
                            https://github.com/organizations/FlossWare

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


Mime
View raw message