2

My ANT build script uses a WebSphere command called createEJBStubs that produces a JAR file with everything plus one new generated class, namely: com/myapp/services/_User_Service_Stub.class.

Since this stub class is only used for running JUnit tests at dev time, I would like it to be in its own JAR file.

How can I tell ANT to copy everything in AAA.JAR that matches, say, _*Stub.class and copy only those files into BBB.JAR (also, maintaining the same directory/package structure)?

Any ideas or pointers would be GREATLY appreciated! Thanks,

Rob

  • Possible duplicate. See [How do I copy files into an existing JAR with Ant?](http://stackoverflow.com/questions/518207/how-do-i-copy-files-into-an-existing-jar-with-ant) as well as [ant : jar and zipfileset - copy files from one JAR into another](http://stackoverflow.com/questions/3837073/ant-jar-and-zipfileset-copy-files-from-one-jar-into-another). – Christopher Peisert Jun 22 '12 at 18:25

1 Answers1

8

Ok -- answering my own question -- that was surprisingly easy. Sorry I asked.

<unzip src="AAA.JAR" dest="./temp">
  <patternset>
    <include name="**/_*Stub.class" />
  </patternset>
</unzip>

<zip destfile="BBB.JAR" basedir="./temp" />

Thanks ANT.

  • 1
    Did you try answer from http://stackoverflow.com/questions/3837073/ant-jar-and-zipfileset-copy-files-from-one-jar-into-another - that avoids unzip. – Jayan Jun 23 '12 at 06:16