![](/img/trans.png)
[英]Directory not creating other than WEB-INF & META-INF in WAR using Maven pom.xml
[英]Using ant war task to include files in WEB-INF directory
我正在使用ant構建我的網絡應用程序。 我確信這很簡單,但我無法弄清楚如何告訴ant在WEB-INF目錄中創建一個特定的文件夾並將文件復制到它。
我的螞蟻戰爭任務看起來像這樣:
<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>
所有文件集元素都可以工作,即它們包含war文件根目錄中的pdf,jsp和image文件。
但是如果我想在war文件的WEB-INF目錄中創建一個子目錄並在其中包含文件,我該如何指定? 例如,我想在war文件中包含WEB-INF / TagLibraryDescriptors / MyTagLib.tld,或者我想在war文件中創建一個WEB-INF / JSP文件夾並將所有JSP文件復制到它。
謝謝。
OP在這里,感謝所有的回復。 我發現了另一個解決方案 - 有一個webinf元素可以包含在war任務中。
這會將源JSPs文件夾中的文件復制到war文件中的WEB-INF文件夾中:
<webinf dir="${home.dir}/JSPs"
includes="**/*.jsp">
</webinf>
而這會將文件從源JSPs文件夾復制到WEB-INF / JSPs文件夾(我的首選):
<webinf dir="${home.dir}"
includes="/JSPs/**/*.jsp">
</webinf>
我想我會堅持這個解決方案,但感謝你的回復。
作為嵌套webinf
元素的替代方法,您還可以使用zipfileset
元素,該元素允許您在存檔中指定源文件夾和路徑前綴:
<zipfileset dir="${home.dir}/JSPs" includes="**/*.jsp" prefix="WEB-INF/JSPs"/>
嘗試在項目中創建此目錄,然后添加如下所示的文件集:
<fileset dir="${home.dir}/WEB-INF/mydirectory/*">
<include name="**/*"/>
</fileset>
為什么不創建你需要mkdir方式的目錄結構?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.