Ant 打包war 生成文件内容build.xml
Ant 打包war 生成文件内容build.xml
1. 打包文件内容
Xml代码
- <?xml version="1.0" encoding="UTF-8"?>
- <project name="newbssqyl" basedir="." default="makewar">
- <property name="classpath_lib" value="WebContent/WEB-INF/lib" />
- <property name="sources" value="${basedir}/src"/>
- <path id="classpath">
- <fileset dir="${classpath_lib}">
- <include name="*.jar"/>
- </fileset>
- </path>
- <property name="debuglevel" value="source,lines,vars"/>
- <property name="target" value="1.6"/>
- <property name="source" value="1.6"/>
- <target name="init">
- <property name="build" value="build/destination/webapp"></property>
- <property name="src" value="src"></property>
- <mkdir dir="${build}"/>
- <mkdir dir="${build}\WEB-INF"/>
- <mkdir dir="${build}\WEB-INF\classes"/>
- <mkdir dir="${build}\WEB-INF\lib"/>
- <copy todir="${build}">
- <fileset dir="${basedir}\WebContent">
- <include name="WEB-INF/**" />
- <include name="**" />
- </fileset>
- </copy>
- </target>
- <target name="complie" depends="init">
- <javac srcdir="${src}" destdir="${build}/WEB-INF/classes" classpathref="classpath">
- </javac>
- </target>
- <target name="makewar" depends="complie">
- <war warfile="${build}/newbssqyl.war" webxml="${build}/WEB-INF/web.xml">
- <lib dir="${build}/WEB-INF/lib">
- <include name="**" />
- </lib>
- <classes dir="${build}/WEB-INF/classes"/>
- <fileset dir="${build}"/>
- </war>
- </target>
- </project>
复制代码2. 将文件放到项目根目录中
\newbssqyl
3.运行命令
Java代码
- E:\刘庆\AntProjectTest\test\newbssqyl>ant makewar
- Buildfile: E:\刘庆\AntProjectTest\test\newbssqyl\build.xml
- init:
- complie:
- [javac] E:\刘庆\AntProjectTest\test\newbssqyl\build.xml:34: warning: 'includ
- eantruntime' was not set, defaulting to build.sysclasspath=last; set to false fo
- r repeatable builds
- makewar:
- [war] Building war: E:\刘庆\AntProjectTest\test\newbssqyl\build\destinatio
- n\webapp\newbssqyl.war
- BUILD SUCCESSFUL
- Total time: 1 minute 59 seconds
- E:\刘庆\AntProjectTest\test\newbssqyl>
复制代码OK 生成成功
修正文件
Xml代码
- 1.<?xml version="1.0" encoding="UTF-8"?>
- 2.
- 3.<project name="newbssqyl" basedir="." default="makewar">
- 4. <property name="classpath_lib" value="WebContent/WEB-INF/lib" />
- 5. <property name="sources" value="${basedir}/src"/>
- 6.
- 7. <path id="classpath">
- 8. <!--添加lib 中的jar 包到软件中-->
- 9. <fileset dir="${classpath_lib}">
- 10. <include name="*.jar"/>
- 11. </fileset>
- 12. <!--添加lib 之外的包-->
- 13. <fileset dir="D:\Tomcat 6.0\lib">
- 14. <include name="*.jar" />
- 15. </fileset>
- 16. </path>
- 17.
- 18. <property name="debuglevel" value="source,lines,vars"/>
- 19.
- 20. <property name="target" value="1.6"/>
- 21. <property name="source" value="1.6"/>
- 22.
- 23. <target name="init">
- 24. <property name="build" value="build/destination/webapp"></property>
- 25. <property name="src" value="src"></property>
- 26. <mkdir dir="${build}"/>
- 27. <mkdir dir="${build}\WEB-INF"/>
- 28. <mkdir dir="${build}\WEB-INF\classes"/>
- 29. <mkdir dir="${build}\WEB-INF\lib"/>
- 30. <copy todir="${build}">
- 31. <fileset dir="${basedir}\WebContent">
- 32. <include name="WEB-INF/**" />
- 33. <include name="**" />
- 34.
- 35. </fileset>
- 36. </copy>
- 37. </target>
- 38. <target name="complie" depends="init">
- 39. <!--添加源文件内容和编码utf-8 因为默是系统的本地时间-->
- 40. <javac srcdir="${src}" destdir="${build}/WEB-INF/classes" encoding="utf-8" classpathref="classpath">
- 41. </javac>
- 42.
- 43. </target>
- 44. <!--生成war 包结构-->
- 45. <target name="makewar" depends="complie">
- 46. <war warfile="${build}/newbssqyl.war" webxml="${build}/WEB-INF/web.xml">
- 47. <lib dir="${build}/WEB-INF/lib">
- 48. <include name="**" />
- 49. </lib>
- 50. <classes dir="${build}/WEB-INF/classes"/>
- 51. <fileset dir="${build}"/>
- 52. </war>
- 53.
- 54. </target>
- 55.
- 56.</project>
复制代码
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论