使用Ant将文件和文件夹复制到WEB-INF

使用Ant将文件和文件夹复制到WEB-INF,ant,copy,war,Ant,Copy,War,我想将.properties文件从某个位置复制到WEB-INF/classes/com/infiniti文件夹(在WAR文件中) 我已经通过了这个链接 我可以使用它将.properties文件复制到WEB-INF/classes/但不能复制到WEB-INF/classes/com/infiniti 我使用的代码是: <war destfile="${deploy}/acc.war" webxml="${warSrc}/web/WEB-INF/web.xml">

我想将.properties文件从某个位置复制到WEB-INF/classes/com/infiniti文件夹(在WAR文件中)

我已经通过了这个链接 我可以使用它将.properties文件复制到WEB-INF/classes/但不能复制到WEB-INF/classes/com/infiniti

我使用的代码是:

<war destfile="${deploy}/acc.war" webxml="${warSrc}/web/WEB-INF/web.xml">
            <lib dir="${lib}">
.......
.......
.......
            <classes dir="${configHome}/config/com/infiniti">
                <include name="accredit.properties" />
            </classes>

...
....
.......
</war>

.......
.......
.......
...
....
.......
我还需要将${configHome}/resources/com/infiniti/errorcode文件夹复制到 WEB-INF/classes/com/infiniti


这可以使用Ant吗?

是的,可以使用Ant。只需使用“复制”或“同步”命令移动文件:

<copy todir="${distribution}/location" file="${local.path}/data/file.txt">
</copy>

您还可以使用以下规则进行复制:

<copy includeemptydirs="false" todir="${combined.bin}">
  <fileset dir="${buildbin}"/>
  <fileset dir="${output2buildbin}"/>
  <fileset dir="${output3buildbin}"/>
</copy>

使用同步:

<sync includeemptydirs="false" todir="${distres}">
  <fileset dir="${buildres}">
    <include name="logging/**" />
  </fileset>
</sync>

任务在其文档站点上描述:

相同的“文件集”声明适用于war任务:

Examples

Assume the following structure in the project's base directory:

thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif

then the war file myapp.war created with

<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
  <fileset dir="src/html/myapp"/>
  <fileset dir="src/jsp/myapp"/>
  <lib dir="thirdparty/libs">
    <exclude name="jdbc1.jar"/>
  </lib>
  <classes dir="build/main"/>
  <zipfileset dir="src/graphics/images/gifs"
              prefix="images"/>
</war>

will consist of

WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif
示例
在项目的基本目录中采用以下结构:
第三方/libs/jdbc1.jar
第三方/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
然后使用创建war文件myapp.war
将包括
WEB-INF/WEB.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
image/small/logo.gif
image/large/logo.gif

是的,您可以像这样使用示例

<war destfile="${deploy}/acc.war" webxml="${warSrc}/web/WEB-INF/web.xml">
...
    <zipfileset dir="${configHome}/config/com/infiniti" includes="**/*.properties" prefix="WEB-INF/classes/com/infiniti"/>

...

我尝试了复制,但似乎在war标记下不支持复制…在使用“war不支持嵌套的“copy”元素”时给了我这个错误,它应该支持文件集。请看文档中的示例。非常感谢Michele…你每天为我节省了2个小时的任务:)…工作顺利…我问题的第二部分也是如此(复制文件夹)…我用过这个