2007-12-21
完整ant自动编译打包和发布脚本
关键字: ant脚本xml 代码
- <?xml version="1.0" encoding="UTF-8"?>
- <project basedir="." default="build" name="potato">
- <property file="ant.properties"/>
- <property environment="env"/>
- <property name="tomcat.path" value="${tomcat.path}"/>
- <echo message="tomcat.path = ${tomcat.path}"/>
- <property name="websrc.dir" value="WebContent"/>
- <property name="src.dir" value="src"/>
- <property name="build.dir" value="build"/>
- <property name="dist.dir" value="dist"/>
- <property name="deploy.dir" value="${tomcat.path}/webapps"/>
- <property name="dest.jar" value="potato.jar"/>
- <property name="dest.war" value="potato.war"/>
- <property name="jdk.source" value="1.5"/>
- <property name="jdk.target" value="1.5"/>
- <property name="src.zipfile" value="potato.zip"/>
- <property name="build.out" value="${build.dir}/WEB-INF/classes" />
- <property name="dest.zip" value="potato.zip" />
- <property name="deploy.web.dir" value="potato" />
- <patternset id="jar.pattern"><include name="**/*.jar"/></patternset>
- <patternset id="config.pattern">
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- <include name="**/*.prop"/>
- <include name="**/*.conf"/>
- <include name="**/*.tld"/>
- <include name="**/*.ftl"/>
- </patternset>
- <path id="compile.classpath">
- <fileset dir="${tomcat.path}/common/lib">
- <patternset refid="jar.pattern"/>
- </fileset>
- <fileset dir="${websrc.dir}/WEB-INF/lib">
- <patternset refid="jar.pattern"/>
- </fileset>
- </path>
- <patternset id="build.pattern">
- <include name="**/*.jar"/>
- <include name="**/*.class"/>
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- <include name="**/*.prop"/>
- <include name="**/*.conf"/>
- <include name="**/*.tld"/>
- <include name="**/*.ftl"/>
- <include name="**/*.jsp"/>
- <include name="**/*.htm"/>
- <include name="**/*.html"/>
- <include name="**/*.js"/>
- <include name="**/*.css"/>
- <include name="**/*.swf"/>
- <include name="**/*.jpg"/>
- <include name="**/*.gif"/>
- <include name="**/*.png"/>
- <include name="**/*.rar"/>
- <include name="**/*.wmv"/>
- <include name="**/*.mp3"/>
- <include name="**/*.3gp"/>
- <include name="**/*.doc"/>
- <exclude name="WEB-INF/**/*"/>
- <exclude name="**/web.xml"/>
- </patternset>
- <patternset id="src.pattern">
- <include name="**/*.java"/>
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- <include name="**/*.prop"/>
- <include name="**/*.conf"/>
- <include name="**/*.tld"/>
- <include name="**/*.ftl"/>
- <include name="**/*.jsp"/>
- <include name="**/*.htm"/>
- <include name="**/*.html"/>
- <include name="**/*.js"/>
- <include name="**/*.css"/>
- <include name="**/*.swf"/>
- <include name="**/*.jpg"/>
- <include name="**/*.gif"/>
- <include name="**/*.png"/>
- <exclude name="**/web.xml"/>
- </patternset>
- <tstamp>
- <format property="date.current" pattern="yyyyMMdd"/>
- <format property="time.current" pattern="HHmmss"/>
- </tstamp>
- <target name="clean">
- <delete dir="${build.dir}"/>
- <delete dir="${dist.dir}"/>
- <!--delete file="${dist.dir}/${dest.war}" /-->
- </target>
- <target name="init">
- <mkdir dir="${build.dir}"/>
- <mkdir dir="${build.dir}/classes"/>
- <mkdir dir="${dist.dir}"/>
- <mkdir dir="${build.out}"/>
- </target>
- <target name="compile" depends="init">
- <javac srcdir="${src.dir}" destdir="${build.dir}/classes" debug="true">
- <classpath refid="compile.classpath" />
- </javac>
- <copy todir="${build.dir}/classes">
- <fileset dir="${src.dir}">
- <patternset refid="config.pattern"/>
- </fileset>
- </copy>
- </target>
- <!-- deploy complie-->
- <target name="deploycompile" depends="init">
- <copy todir="${build.dir}">
- <fileset dir="${websrc.dir}">
- <exclude name="**/*.java" />
- <exclude name="**/servlet-api.jar" />
- <exclude name="resource/**/*"/>
- <exclude name="images/**/*"/>
- </fileset>
- </copy>
- <javac srcdir="${src.dir}" debug="true" destdir="${build.out}" >
- <classpath refid="compile.classpath" />
- </javac>
- <copy todir="${build.out}">
- <fileset dir="${src.dir}">
- <exclude name="**/*.java" />
- <exclude name="resource/**/*"/>
- <exclude name="images/**/*"/>
- </fileset>
- </copy>
- </target>
- <target name="archive" depends="compile">
- <delete file="${dist.dir}/${dest.jar}" />
- <jar destfile="${dist.dir}/${dest.jar}"
- basedir="${build.dir}/classes" />
- </target>
- <target name="build" depends="compile">
- <delete file="${dist.dir}/${dest.war}" />
- <war destfile="${dist.dir}/${dest.war}" webxml="${websrc.dir}/WEB-INF/web.xml">
- <classes dir="${build.dir}/classes"/>
- <webinf dir="${websrc.dir}/WEB-INF"/>
- <!--lib dir="${websrc.dir}/WEB-INF/lib"/-->
- <fileset dir="${websrc.dir}">
- <patternset refid="build.pattern"/>
- <exclude name="resource/**/*"/>
- <exclude name="images/**/*"/>
- </fileset>
- </war>
- <!--copy file="${dist.dir}/${dest.war}" tofile="${dist.dir}/${date.current}.${time.current}_program_${dest.war}"/-->
- </target>
- <target name="fullbuild" depends="compile">
- <delete file="${dist.dir}/${dest.war}" />
- <war destfile="${dist.dir}/${dest.war}" webxml="${websrc.dir}/WEB-INF/web.xml">
- <classes dir="${build.dir}/classes"/>
- <webinf dir="${websrc.dir}/WEB-INF"/>
- <!--lib dir="${websrc.dir}/WEB-INF/lib"/-->
- <fileset dir="${websrc.dir}">
- <patternset refid="build.pattern"/>
- </fileset>
- </war>
- <copy file="${dist.dir}/${dest.war}" tofile="${dist.dir}/${date.current}.${time.current}_full_${dest.war}"/>
- </target>
- <target name="deploy" depends="unzip">
- <echo message="${deploy.dir}" />
- <delete dir="${build.dir}"/>
- </target>
- <target name="zip" depends="deploycompile">
- <echo message="now stopping tomcat service"/>
- <exec executable="sc">
- <arg line="stop Tomcat5"/>
- </exec>
- <delete file="${dist.dir}/${dest.zip}" />
- <zip destfile="${deploy.dir}/${dest.zip}">
- <fileset dir="${build.dir}">
- <include name="**/*"/>
- <exclude name="resource/**/*"/>
- <exclude name="images/**/*"/>
- </fileset>
- </zip>
- </target>
- <target name="unzip" depends="zip">
- <sleep seconds="60"/>
- <unzip dest="${deploy.dir}/${deploy.web.dir}" overwrite="true" src="${deploy.dir}/${dest.zip}">
- </unzip>
- <echo message="now starting tomcat service"/>
- <exec executable="sc">
- <arg line="start Tomcat5"/>
- </exec>
- </target>
- </project>
发表评论
- 浏览: 13822 次

- 详细资料
搜索本博客
我的相册
ttttt
共 7 张
共 7 张
链接
最新评论
-
Java实现按照要求的尺寸对 ...
只能缩小不能放大啊!
-- by likehibernate -
tomcat 6 el表达式的问题
tomcat6 中对5.0中这样的判断 ${not empty command ...
-- by hf200012 -
tomcat 6 el表达式的问题
这个是Tomcat6 的bug:https://issues.apache.or ...
-- by codeutil -
Java实现按照要求的尺寸对 ...
透明的png图片缩放后的图片就不透明了! 怎么解决啊?
-- by form_rr -
[以解决]请教iBatis批量 ...
问题以解决,是因为#oknos#这个地方的#换成$就可以,因为Ibatis认为这 ...
-- by hf200012






评论排行榜