蚂蚁:排除从合并后的jar文件的文件 [英] Ant: Exclude files from merged jar file

查看:235
本文介绍了蚂蚁:排除从合并后的jar文件的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关Java项目我想合并所有这取决于成Apache Ant的,这我已经成功地做​​到创建的主罐第三方罐。

For a java project I'd like to merge all third-party jars it depends on into the main jar created by Apache Ant, which I already managed to do.

问题是,一些JAR-文件在签名文件的 META-INF -directories,所以当我尝试运行我的jar文件,我收到错误信息无效的签名文件的摘要清单主要属性。之后,我手动删除签名文件中的错误已经一去不复返了。

The problem is that some of these jar-files have signature-files in their META-INF-directories, so when I try to run my jar-file, I get the error message "Invalid signature file digest for Manifest main attributes". After I delete the signature-files manually the error is gone.

我试图来过滤签名在我的蚂蚁文件与排除文件出来 -attribute或排除 -tag,但似乎没有任何效果。

I tried to filter the signature files out in my ant-file with an excludes-attribute or an exclude-tag, but nothing seems to have any effect.

这是蚂蚁的任务:

<target name="jar" description="Creates the jar file">
  <mkdir dir="${jar}"/>
  <jar destfile="${jar}/${ant.project.name}.jar" level="9" filesetmanifest="mergewithoutmain">
    <zipgroupfileset dir="${lib}" includes="*.jar"/>
    <zipfileset dir="${class}"/>
    <manifest>
      <attribute name="Main-Class" value="${mainclass}"/>
    </manifest>
  </jar>
</target>

我怎样才能在这个蚂蚁任务的滤除产生的jar文件?感谢您的帮助!

How can I filter files from the resulting jar in this ant-task? Thanks for your help!

推荐答案

据我所知没有办法使用&LT时过滤; zipgroupfileset计算值:在包括使用有适用于拉链/不包括被合并,而不是在其中的内容。

To the best of my knowledge there's no way to filter when using <zipgroupfileset>: the include/excludes used there apply to the zips to be merged, not the content within them.

如果你有一个著名的集JAR的合并,你可以使用单独的&LT; zipset&GT;条目,每一个;这种方法允许使用包含/排除过滤源存档的内容。

If you have a well-known set of JARs to merge you could use individual <zipset> entries for each one; this approach allows using include/exclude to filter the contents of the source archive.

另一种方法是简单地解压缩一切都变成一个临时位置,删除/修改不需要位,那么一切都压缩备份。

An alternative approach is to simply unzip everything into a temporary location, remove/modify the unwanted bits, then zip everything back up.

这篇关于蚂蚁:排除从合并后的jar文件的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆