I'm using ant to build my web-app. I'm sure this is simple but I can't figure out how to tell ant to create a specific folder in the WEB-INF directory and copy files to it.
My ant war task looks like this:
<target name="warItUp" depends="compile">
<war destfile="MyApp.war" webxml="${home.dir}\WEB-INF\web.xml">
<classes dir="${classes.dir}"/>
<classes file="${src.dir}/hibernate.cfg.xml"/>
<classes dir="${src.dir}" includes="**/*.hbm.xml"/>
<!-- Include the PDF files -->
<fileset dir="${home.dir}/PDFs">
<include name="**/*.pdf"/>
</fileset>
<!-- Include the JSP files -->
<fileset dir="${home.dir}/JSPs">
<include name="**/*.jsp"/>
</fileset>
<!-- Include the images -->
<fileset dir="${home.dir}/images">
<include name="**/*"/>
</fileset>
</war>
All the fileset elements work ie they include the pdf, jsp and image files in the root directory of the war file.
But if I want to create a sub-directory in the WEB-INF directory of the war file and include files in it how do I specify that? eg say I wanted to include WEB-INF/TagLibraryDescriptors/MyTagLib.tld in the war file or if I wanted to create a WEB-INF/JSP folder in my war file and copy all JSP files to it.
Thanks.
OP here, thanks for all the responses. I found another solution - there is a webinf element that can be included in the war task.
This will copy files from the source JSPs folder into the WEB-INF folder in the war file:
<webinf dir="${home.dir}/JSPs"
includes="**/*.jsp">
</webinf>
whereas this will copy files from the source JSPs folder into the WEB-INF/JSPs folder (my preferred choice):
<webinf dir="${home.dir}"
includes="/JSPs/**/*.jsp">
</webinf>
I think I'll stick with this solution but thanks for the responses.
作为嵌套webinf
元素的替代方法,您还可以使用zipfileset
元素,该元素允许您在存档中指定源文件夹和路径前缀:
<zipfileset dir="${home.dir}/JSPs" includes="**/*.jsp" prefix="WEB-INF/JSPs"/>
Try to create this directory into your project and then just add fileset like the following:
<fileset dir="${home.dir}/WEB-INF/mydirectory/*">
<include name="**/*"/>
</fileset>
为什么不创建你需要mkdir方式的目录结构?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.