使用 zipgroupfileset 从 Ant Build 中排除 Jar [英] Exclude Jar from Ant Build using zipgroupfileset

查看:39
本文介绍了使用 zipgroupfileset 从 Ant Build 中排除 Jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个包含 Filter 的 Jar 项目.编译Filter代码时需要使用servlet-api.jar.

I have created a Jar Project which contains Filter. I need to use servlet-api.jar when I compile the Filter code.

但是,当我想在另一个应用程序中使用 Jar 时,我希望以排除 servlet-api.jar 的方式构建 jar.

But when I want to use the Jar in another application, I want to build the jar in such a way that it will exclude servlet-api.jar.

我将 Apache Ant 与 NetBeans 8 一起使用:
我在 build.xml 中添加了以下代码.

I am using Apache Ant with NetBeans 8:
I have added below code in build.xml.

<target name="-post-jar">
    <jar destfile="dist/MyJar.jar">
        <zipfileset src="dist/MyJarAsLibrary.jar"/>
        <zipgroupfileset dir="dist/lib/." excludes="javax/*"/>
    </jar>
</target>

我使用过 Apache Ant zipgroupfileset.但是我在谷歌上搜索我发现了文件的排除项.我尝试将 servlet 包排除为 javax/*,但没有奏效.不知道如何排除特定的包.我发现 zipfileset 很少有排除项,但我需要使用 zipgroupfileset 并排除 javax.servelt.* 包.

I have used Apache Ant zipgroupfileset. But I searched on google I found the excludes for files. I tried with excluding the servlet packages as javax/*, but it did not work. No Idea how to exclude specific packages. I found few excludes with zipfileset, but I need to use zipgroupfileset and exclude the javax.servelt.* packages.

推荐答案

zipgroupfilesetexcludes 属性用于选择存档以从中挑选条目,而不是过滤档案的内容.zipgroupfileset 始终包含匹配存档中包含的所有内容.

The excludes attribute of zipgroupfileset is used to select the archives to pick entries from, not to filter the contents of the archives. zipgroupfileset always contains everything included inside the matched archives.

如果您知道哪个存档包含 servlet 类,那么简单的解决方案是将其从 zipgroupfileset 中排除并添加一个显式的 zipfileset.

The simple solution if you know which archive contains the servlet classes is to exclude it from the zipgroupfileset and add an explicit zipfileset.

如果您不知道存档,您可以使用 archives 资源集合模拟 zipgroupfileset 并将其包装到 restrict 容器中.类似的东西

If you don't know the archive, you can mimic zipgroupfileset using the archives resource collection and wrap that into a restrict container. Something like

<restrict>
  <archives>
    <zips>
      <fileset dir="dist/lib/"/>
    </zips>
  </archives>
  <not>
    <name name="javax/servlet/*"/>
  </not>
</restrict>

这篇关于使用 zipgroupfileset 从 Ant Build 中排除 Jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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