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-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@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-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to