我想将.properties文件从某个位置复制到我的 WEB-INF / classes / com / infiniti 文件夹(在WAR文件中)。
我已浏览此链接How to get Ant to copy properties file to classes directory 使用我可以将.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 /类/ COM / INFINITI
这可以使用Ant吗?
答案 0 :(得分:9)
是的,你可以使用像这样的ZipFileSet
<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"/>
答案 1 :(得分:0)
是的,可以使用蚂蚁。只需使用复制或同步命令移动文件:
<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>
任务在他们的doc站点上描述:
http://ant.apache.org/manual/Tasks/copy.html
相同的'fileset'声明适用于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