使用zipgroupfileset从Ant Build中排除Jar [英] Exclude Jar from Ant Build using zipgroupfileset
问题描述
我创建了一个包含过滤器
的Jar项目。
当我编译过滤器
代码时,我需要使用 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时,我想以这样的方式构建jar,它将排除 servlet-api.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
.
我在NetBeans 8中使用Apache Ant:
我在 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 。
但是我在google上搜索了我找到了文件的排除项。
我尝试将servlet包排除为 javax / *
,但它不起作用。
否如何排除特定包裹。
我发现很少有 zipfileset
排除,但我需要使用 zipgroupfileset
并排除 javax.servelt。*
packages。
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.
推荐答案
排除
zipgroupfileset
的属性用于选择存档以从中选择条目,而不是过滤存档的内容。 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屋!