[英]Package Java classes under WEB-INF folder in WAR file
I am using the following to package war file in ANT script 我正在使用以下内容将战争文件打包在ANT脚本中
<target name="war" depends="compile">
<war destfile="${deploy.dir}/vms_war.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${classes.dir}">
<include name="**/*.class"/>
<exclude name="test/**/*.class"/>
</fileset>
<fileset dir="${src.dir}">
<include name="**/*.xml"/>
</fileset>
<fileset dir="${web.dir}">
<include name="**/*.jspx"/>
<include name="**/*.jsp"/>
<include name="**/*.html"/>
<include name="WEB-INF/*.xml"/>
<include name="WEB-INF/lib/*.*"/>
<exclude name="**/web.xml"/>
</fileset>
</war>
</target>
When war is packaged, the structure is as follows 打包战争时,结构如下
--WEB-INF
lib
web.xml
faces-config.xml
--mypackageappname
app
test
Login.class
Authenticate.class
....
What I would like to achieve is when war
is packaged, I would want to put java classes to be under WEB-INF
folder along with lib
folder. 我想实现的是打包打包war
时,我想将java类与lib
文件夹一起放在WEB-INF
文件夹下。
How can I do this? 我怎样才能做到这一点?
The WAR Task documentation says (in part) The nested classes
element specifies a FileSet. WAR Task文档说(部分) ,嵌套classes
元素指定一个FileSet。 All files included in this fileset will end up in the WEB-INF/classes directory of the war file. 该文件集中包含的所有文件都将最终在war文件的WEB-INF / classes目录中。 I think you wanted something like 我想你想要类似的东西
<war destfile="${deploy.dir}/vms_war.war" webxml="${web.dir}/WEB-INF/web.xml">
<classes dir="${classes.dir}" />
<fileset dir="${src.dir}">
<include name="**/*.xml"/>
</fileset>
<fileset dir="${web.dir}">
<include name="**/*.jspx"/>
<include name="**/*.jsp"/>
<include name="**/*.html"/>
<include name="WEB-INF/*.xml"/>
<include name="WEB-INF/lib/*.*"/>
<exclude name="**/web.xml"/>
</fileset>
</war>
Jar up your classes first and tuck that jar
into the war
file afterward. 第一个JAR你的类和掖那jar
到war
文件之后。 Something like this: 像这样:
<target name="war" depends="compile">
<jar jarfile="${web.dir}/WEB-INF/lib/vms.jar">
<fileset dir="${classes.dir}">
<include name="**/*.class"/>
<exclude name="test/**/*.class"/>
</fileset>
</jar>
<war destfile="${deploy.dir}/vms_war.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${src.dir}">
<include name="**/*.xml"/>
</fileset>
<fileset dir="${web.dir}">
<include name="**/*.jspx"/>
<include name="**/*.jsp"/>
<include name="**/*.html"/>
<include name="WEB-INF/*.xml"/>
<include name="WEB-INF/lib/*.*"/>
<exclude name="**/web.xml"/>
</fileset>
</war>
</target>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.