如何将 Ant 路径转换为 FileSet? [英] How do I convert an Ant Path into a FileSet?
问题描述
我正在编写一个 Ant 脚本来将一个项目打包到一个 WAR 文件中.该软件由多个项目组成,具有自己的源目录、库等.
WAR 任务有一个我目前正在处理的嵌套元素 lib
.我目前有一个所需库的引用作为 Path
(包含几个 FileSets
,我在类路径引用中使用.lib
,但是, 希望输入是 FileSet
,它拒绝 Path
.
我尝试将我的 Path
转换为 FileSet
,但后来我没有让它在其他地方用作类路径.
有没有办法将Path
转换成FileSet
?我不想复制粘贴目录.
<fileset dir="${common.path}/lib" includes="*.jar"/><fileset dir="${data.path}/lib" includes="*.jar"/><fileset dir="${gui.path}/lib" includes="*.jar"/><fileset dir="${gui.path}/WebContent/WEB-INF/lib" includes="*.jar"/></路径>
...当与
导致:
您可能有多种选择.
- 您可以提供多个
嵌套元素到
任务.也许这就足够了. - 您可以预先组装所有
lib
文件在一个临时文件中目录,然后只是引用目录作为文件集. - 有一个蚂蚁贡献PathToFileSet 任务,但它需要一个中央根目录,这可能不是你的情况
compile.libs
布局. - 从 Ant 1.8.0 开始,您可以使用 mappedresources.来源:Ant 脚本:防止重复 JARjavac-classpath war-lib
我想我会尝试选项 1.
I'm writing an Ant script to package a project into a WAR file. The software consists of several projects with their own source directories, libraries, etc.
The WAR task has a nested element lib
which I'm currently working on. I currently have a reference of the required libs as a Path
(containing several FileSets
, which I use in a classpath reference. The lib
, however, wants the input to be a FileSet
, and it refuses a Path
.
I tried converting my Path
into a FileSet
, but then I didn't get it to work as a classpath elsewhere.
Is there a way to convert a Path
into a FileSet
? I would hate to copy-paste the directories.
<path id="compile.libs">
<fileset dir="${common.path}/lib" includes="*.jar"/>
<fileset dir="${data.path}/lib" includes="*.jar"/>
<fileset dir="${gui.path}/lib" includes="*.jar"/>
<fileset dir="${gui.path}/WebContent/WEB-INF/lib" includes="*.jar"/>
</path>
...when used with <war ..><../> <lib refid="compile.libs"/> </war>
leads to:
BUILD FAILED build.xml:173: compile.libs doesn't denote a zipfileset or a fileset
You may have several choices.
- You may provide more than one
<lib>
nested element to<war>
task. Maybe this would be enough. - You may preassemble all of your
lib
files in one temporary directory and then just reference that directory as a fileset. - There is an ant-contrib
PathToFileSet task, but it
requires a central root directory,
and this may not be a case with your
compile.libs
layout. - Since Ant 1.8.0 you can use a mappedresources. Source: Ant script: Prevent duplication of JAR in javac-classpath war-lib
I think I would try option 1.
这篇关于如何将 Ant 路径转换为 FileSet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!