<?xml version="1.0" encoding="UTF-8"?> <project name="ant-demo" basedir="." default="build"> <tstamp> <format property="time" pattern="yyyy-MM-dd HH:mm:ss"/> <format property="date" pattern="yyyy-MM-dd"/> </tstamp> <property name="M2_HOME" value="/app/env/apache-maven-3.3.3"/> <property name="RESIN_HOME" value="/app/resin"/> <property name="TOMCAT_HOME" value="/app/tomcat"/> <!--<property environment="SystemVariable"/>--> <property name="repository_address" value="git@git.oschina.net:lerongjinfu/ant-demo.git"/> <property name="srcdir" value="${basedir}/ant-demo"/> <property name="fixdir" value="${basedir}/patch"/> <property name="in_binwar" value="${srcdir}/in-web/target/in-web.war"/> <property name="wechat_binwar" value="${srcdir}/wechat-web/target/wechat-web.war"/> <property name="wechat_qz_binwar" value="${srcdir}/wechat-qz/target/wechat-qz.war"/> <property name="in_dir" value="/app/www/in"/> <property name="wechat_dir" value="/app/www/wechat"/> <property name="wechat_qz_dir" value="/app/www/wechat-qz"/> <property name="in_war" value="/app/www/in.war"/> <property name="wechat_war" value="/app/www/wechat.war"/> <property name="wechat_qz_war" value="/app/www/wechat-qz.war"/> <property name="dbdir" value="${srcdir}/src/main/resources"/> <property name="dbdriver" value="com.mysql.jdbc.Driver"/> <property name="dburl" value="jdbc:mysql://127.0.0.1:3306/?useUnicode=true&characterEncoding=utf8"/> <property name="dbusername" value="root"/> <property name="dbpassword" value="Lr123456"/> <!-- <property name="r" value="HEAD"/> --> <property name="r" value="master"/> <patternset id="resources"> <include name="**/?*.properties"/> <include name="**/?*.xml"/> <include name="**/?*.dtd"/> <include name="**/?*.tld"/> <include name="**/?*.ftl"/> <include name="**/?*.txt"/> <include name="**/?*.vm"/> </patternset> <condition property="usefix"> <available file="${fixdir}" type="dir"/> </condition> <target name="clean"> <delete dir="${srcdir}"/> </target> <target name="patch" if="usefix"> <unzip dest="${srcdir}"> <fileset dir="${fixdir}" includes="*.zip"/> </unzip> </target> <target name="checkout" depends="clean"> <echo message="checkout revision:[${r}]"/> <exec dir="${basedir}" executable="git"> <arg line="clone -b ${r} ${repository_address}"/> </exec> <echo message="checkout complete !"/> </target> <target name="update"> <echo message="update revision:[${r}]"/> <exec dir="${srcdir}" executable="git"> <arg line="pull"/> </exec> <echo message="update complete !"/> </target> <target name="package" depends="patch"> <exec dir="${srcdir}" executable="${M2_HOME}/bin/mvn"> <arg line="clean package -U -DskipTests"/> </exec> </target> <target name="build"> <antcall target="package"/> </target> <target name="rebuild" depends="clean, checkout, build"/> <target name="deploy"> <copy file="${in_binwar}" tofile="${in_war}" overwrite="true"/> <copy file="${wechat_binwar}" tofile="${wechat_war}" overwrite="true"/> <copy file="${wechat_qz_binwar}" tofile="${wechat_qz_war}" overwrite="true"/> </target> <target name="redeploy"> <delete dir="${in_dir}"/> <delete file="${in_war}"/> <delete dir="${wechat_dir}"/> <delete file="${wechat_war}"/> <delete dir="${wechat_qz_dir}"/> <delete file="${wechat_qz_war}"/> <antcall target="deploy"/> </target> <!-- tomcat --> <target name="stop"> <exec executable="${TOMCAT_HOME}/bin/catalina.sh" failonerror="false"> <arg value="stop"/> </exec> <sleep seconds="15"/> </target> <target name="start"> <exec executable="${TOMCAT_HOME}/bin/catalina.sh" failonerror="false"> <arg value="start"/> </exec> <waitfor maxwait="5" maxwaitunit="second" checkevery="500"> <http url="http://127.0.0.1:8080/ping.html"/> </waitfor> <echo message="ok"/> </target> <target name="auto" depends="stop, redeploy, start"> <echo message="DONE!!!!"/> </target> <target name="auto_t" depends="stop, start"> <echo message="DONE!!!!"/> </target> <target name="help"> <echo message="Ant 参数说明"/> <echo message="- clean : 删除所有源程序"/> <echo message="- checkout : 从GIT获取最新的源程序"/> <echo message="- build : 编译部署项目 : [*默认]"/> <echo message="- rebuild : 依次执行 clean, checkout, build"/> <echo message="- patch : 解压缩patch目录下的zip包,并拷贝到src目录"/> <echo message="- deploy : 部署到www目录"/> <echo message="- redeploy : 删除旧代码部署到www目录"/> <echo message="- start : 启动tomcat"/> <echo message="- stop : 停止tomcat"/> </target> </project>
转载于:https://my.oschina.net/u/3664884/blog/1593702