Is there a way in ANT to extract one class file from a JAR and put it in another JAR?

拈花ヽ惹草 提交于 2019-12-11 01:34:50

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/11161539/is-there-a-way-in-ant-to-extract-one-class-file-from-a-jar-and-put-it-in-another

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!