Ant打包war文件
来源:互联网 发布:2016年人口老龄化数据 编辑:程序博客网 时间:2024/05/19 23:04
J2EE发布web项目打包war 文件。 压缩JS,CSS文件。
把deploy文件夹复制到项目根目录。运行ant脚本,即可打包war文件。
deploy文件下载地址:http://download.csdn.net/detail/w123456h19/5624633
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="buildSanFull" name="项目War包发布"><property name="build.number" value="1.0.0" />
<!-- 源码地址 -->
<property name="src.dir" value="src"/>
<!-- 应用名称-->
<property name="appname" value="SanFullVisit" />
<!-- 目标目录 , 如deploy-->
<property name="deploy.dir" value="${basedir}/deploy" />
<!-- 源目录 -->
<property name="web.dir" value="${basedir}/WebRoot"/>
<!-- 编译后代码地址 -->
<property name="class.dir" value="${deploy.dir}/output/WebRoot/WEB-INF/classes"/>
<!-- web下jar目录 -->
<property name="project.web.lib" value="WebRoot/WEB-INF/lib"/>
<!-- CSS,JS压缩支持库 -->
<property name="compress.lib" value="${deploy.dir}/lib/yuicompressor-2.4.2.jar" />
<!-- 清空发布前环境 -->
<target name="clean">
<!-- 删除以前编译的war包 -->
<delete verbose="true" file="${deploy.dir}/${appname}.war"/>
<!-- 删除准备打包的代码目录 -->
<delete includeEmptyDirs="true" dir="${deploy.dir}/output/WebRoot"/>
<!-- 删除准备编译后的代码目录 -->
<delete dir="${class.dir}"/>
<!-- 创建准备编译后的代码目录 -->
<mkdir dir="${class.dir}"/>
<echo message="环境清理结束"/>
</target>
<!-- jar地址 -->
<path id="classpath">
<fileset dir="${project.web.lib}">
<include name="*.jar"/>
</fileset>
</path>
<!-- 编译项目-->
<target name="compile" depends="clean">
<javac destdir="${class.dir}" encoding="UTF8" optimize="true" debug="on">
<src path="${src.dir}" />
<classpath refid="classpath"/>
</javac>
<!--拷贝配置文件等-->
<copy todir="${web.dir}/WEB-INF/classes" overwrite="true">
<fileset dir="${src.dir}">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<!-- 准备项目文件到output目录 -->
<target name="output" depends="compile">
<copy todir="${deploy.dir}/output/WebRoot" overwrite="true">
<fileset dir="${web.dir}">
<include name="**/*.html"/>
<include name="**/*.htm"/>
<include name="**/*.jsp"/>
<include name="**/*.css"/>
<include name="**/*.js"/>
<include name="**/*.xml"/>
<include name="**/*.jpg"/>
<include name="**/*.png"/>
<include name="**/*.gif"/>
<include name="**/*.MF"/>
<include name="**/*.jar"/>
</fileset>
</copy>
<copy todir="${deploy.dir}/output/WebRoot/Web-INF/classes">
<fileset dir="${src.dir}">
<include name="**/*.properties"/>
<include name="**/*.sql"/>
<include name="**/*.wsdl"/>
<include name="**/*.wsdd"/>
</fileset>
</copy>
<!-- 创建手机更新包存放目录 -->
<mkdir dir="${deploy.dir}/output/WebRoot/update"/>
<!-- ============================================= -->
<!-- 压缩CSS,JS -->
<!-- ============================================= -->
<echo message="yuicompressor开始CSS压缩"/>
<apply executable="java" parallel="false" failonerror="true" dest="${deploy.dir}/output/WebRoot" append="false" force="true">
<fileset dir="${deploy.dir}/output/WebRoot" includes="**/*.css" />
<arg line="-jar" />
<arg path="${compress.lib}" />
<arg line="--charset utf-8" />
<srcfile />
<arg line="-o" />
<mapper type="glob" from="*.css" to="*.css" />
<targetfile />
</apply>
<echo message="yuicompressor开始JS压缩"/>
<apply executable="java" parallel="false" failonerror="true" dest="${deploy.dir}/output/WebRoot" append="false" force="true">
<fileset dir="${deploy.dir}/output/WebRoot" includes="**/*.js" />
<arg line="-jar" />
<arg path="${compress.lib}" />
<arg line="--charset utf-8" />
<srcfile />
<arg line="-o" />
<mapper type="glob" from="*.js" to="*.js" />
<targetfile />
</apply>
<echo message="yuicompressor压缩完成"/>
</target>
<!-- ============================================= -->
<!-- build .war file -->
<!-- ============================================= -->
<target name="buildSanFull" depends="output">
<war destfile="${deploy.dir}/output/${appname}.war" webxml="${deploy.dir}/output/WebRoot/WEB-INF/web.xml" defaultexcludes="true" >
<fileset dir="${deploy.dir}/output/WebRoot">
<exclude name="**/*.log" />
<exclude name="**/work/**" />
<exclude name="**/tmp/**" />
</fileset>
</war>
<delete includeEmptyDirs="true" dir="${deploy.dir}/output/WebRoot"/>
</target>
</project>
- Ant打包war文件
- ant + ivy 打包 war
- Ant War 打包
- Ant 打包war 生成文件内容build.xml
- Ant 打包war 生成文件内容build.xml
- Ant 打包war 生成文件内容build.xml
- Ant 打包war 生成文件内容build.xml
- ant 打包war 相关操作
- ant build.xml 打包war
- 打包生成war文件
- 打包生成war文件
- 用Ant打包war的简单流程
- 用Ant打包war的简单流程
- 用ANT打包WAR的流程
- 用Ant打包war的简单流程
- 使用ant打包WAR,超详细教程
- ANT在J2EE项目中预编译JSP和打包WAR/EAR文件
- 打包war和war文件部署
- 好的学习网站,设计类、网站类、编程类
- centos6 编译 安装 vlc
- Oracle日志文件管理与查看
- mysql主从复制中的几个DB
- Arcgis镶嵌数据集java代码操作
- Ant打包war文件
- Linq to sql 调用
- android第二天--hello world 以及2013.6.21一天工作
- 整合Ant
- mysql5.1多实例+主从配置脚本--基于MYISAM
- 网页选项卡标题前显示图标
- linux下mysql配置文件my.cnf
- Android提高启动速度的实现方法
- 澳门博彩业数据分析解决方案