使用 Jar Jar 链接排除空目录
我正在使用 Jar Jar 链接 中的 Ant 任务来嵌入来自第 3 方 jar 文件的类(objenesis) 在我的可分发 jar 文件 (example.jar) 中。 Jar Jar 会将原始包 (org.objenesis) 中的类转换为我选择的类之一。
它可以工作,但会在可分发的 jar 中留下空目录。
这是一个简化的 build.xml:
<target name="jar" depends="compile">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="lib/jarjar-1.1.jar"/>
<jarjar jarfile="dist/example.jar" excludes="org.objenesis.**">
<fileset dir="build/classes/main"/>
<zipfileset src="lib/objenesis-1.2.jar"/>
<rule pattern="org.objenesis.**" result="org.thirdparty.@1"/>
</jarjar>
</target>
example.jar 的内容示例包括(如预期):
org/thirdparty/Objenesis.class
org/thirdparty/ObjenesisBase.class
但也包括这些空目录(不需要):
org/objenesis/
org/objenesis/instantiator/
org/objenesis/instantiator/basic/
我的问题:如何排除这些空目录?
我尝试了“zap”选项(文档中列出),但没有不工作。
I am using an Ant task from Jar Jar Links to embed classes from a 3rd-party jar file (objenesis) in my distributable jar file (example.jar). Jar Jar will translate classes from the original package (org.objenesis) to one of my choosing.
It works but it leaves empty directories in the distributable jar.
Here is a simplified build.xml:
<target name="jar" depends="compile">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="lib/jarjar-1.1.jar"/>
<jarjar jarfile="dist/example.jar" excludes="org.objenesis.**">
<fileset dir="build/classes/main"/>
<zipfileset src="lib/objenesis-1.2.jar"/>
<rule pattern="org.objenesis.**" result="org.thirdparty.@1"/>
</jarjar>
</target>
A sample of contents of the example.jar includes (as expected):
org/thirdparty/Objenesis.class
org/thirdparty/ObjenesisBase.class
but also these empty directories (undesirable):
org/objenesis/
org/objenesis/instantiator/
org/objenesis/instantiator/basic/
My question: how to I exclude these empty directories?
I tried the "zap" option (listed in the doc), but that didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是 Jar Jar 中的一个已知问题,已在其问题跟踪器中列出:http://code.google.com/p/jarjar/issues/detail?q=empty&id=32
鉴于此问题是在大约三年前提出的,而且似乎尚未得到解决任何牵引力,我假设您的选择是提供修复程序,或者解决它。
利用 Ant 对删除副本上的空目录的支持,解决此问题的示例 Ant 目标如下:
虽然有点蹩脚,但它达到了你想要的。
This appears to be a known issue in Jar Jar, listed in their issue tracker: http://code.google.com/p/jarjar/issues/detail?q=empty&id=32
Given that this was raised almost three years ago and doesn't appear to have got any traction, I suppose your options are to contribute a fix, or to work around it.
An example Ant target to work around it, taking advantage of Ant's support for removing empty directories on copy, would be:
It's a bit grungy, but it achieves what you want.