Copy files and folder to WEB-INF using Ant
I want to copy the .properties file from a specific location to the WEB-INF / classes / com / infiniti folder (in the WAR file).
I followed this link How to get Ant to copy the properties file to the class directory using which I can copy the .properties file to WEB-INF / classes /, but not to WEB-INF / classes / com / infiniti
The code I'm using is:
<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>
Also I need to copy the $ {configHome} / resources / com / infiniti / errorcode folder to WEB-INF / classes / com / infiniti.
Is this possible with Ant?
source to share
yes you can use for example ZipFileSet like this
<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"/>
source to share
Yes, it is possible to use ant. Just use the copy or sync commands to move the file:
<copy todir="${distribution}/location" file="${local.path}/data/file.txt">
</copy>
You can also copy using rules:
<copy includeemptydirs="false" todir="${combined.bin}">
<fileset dir="${buildbin}"/>
<fileset dir="${output2buildbin}"/>
<fileset dir="${output3buildbin}"/>
</copy>
Using sync:
<sync includeemptydirs="false" todir="${distres}">
<fileset dir="${buildres}">
<include name="logging/**" />
</fileset>
</sync>
The tasks are described on the doc website:
http://ant.apache.org/manual/Tasks/copy.html
The same declarative "set of files" applies to a military mission:
Examples
Assume the following structure in the project 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
source to share