<?xml version="1.0"?> <project name="wgj" default="compile_package_public" basedir="."> <property environment="env" /> <!-- 项目属性配置 --> <property name="project.version" value="1.0" /> <!-- 构建路径配置 --> <property name="project.root" value="${basedir}"/> <property name="project.javacode" value="${project.root}"/> <property name="project.webapp" value="${project.root}/WebContent" /> <property name="project.lib" value="${project.webapp}/WEB-INF/lib" /> <!-- target目录变量--> <property name="build.target" value="${basedir}/target"/> <property name="build.classes" value="${build.target}/classes"/> <property name="build.archive" value="${build.target}/archive"/> <!-- javac编译属性配置 --> <property name="javac.encoding" value="utf-8" /> <property name="javac.debug" value="true" /> <property name="javac.deprecation" value="false" /> <property name="javac.verbose" value="false" /> <property name="javac.optimize" value="false" /> <!-- 完成删除build目录-初始化-编译-打包-打标签-上传-发布 --> <target name="compile_package_public" depends="clean,init,compile,assembly,upload,deploy" /> <target name="part" depends="clean,init,compile" /> <target name="all" depends="clean,init,compile,assembly" /> <!-- ***********************删除build目录*************************--> <target name="clean"> <echo message="正在删除构建目录..................."/> <delete dir="${build.target}"/> </target> <!-- ***********************创建编译后的目录*************************--> <target name="init_dest_dir"> <echo message="正在创建构建目录..................."/> <mkdir dir="${build.target}"/> <mkdir dir="${build.classes}"/> <mkdir dir="${build.archive}"/> </target> <!-- **********************生成版本号*******************************--> <target name="create_version_info" description="create version infomation..."> <tstamp> <format property="current.time" pattern="yyyy-MM-dd-HH-mm-ss" timezone="GMT+8"/> </tstamp> <concat destfile="${build.target}/version.txt">CURRENT VERSION: ${current.time}</concat> </target> <!-- 用于组装所有的代码--> <target name="init" depends="init_dest_dir,create_version_info" description="Initialize enviroment properties..."> <record name="${build.target}/buildoutput.txt" loglevel="verbose"/> </target> <!-- ***********************设置java编译时需要的ClASSPATH *************************--> <target name="setup.classpath"> <path id="build.path"> <fileset dir="${project.lib}"> <include name="**/*.jar" /> <include name="**/*.zip" /> </fileset> </path> <property name="build.classpath" refid="build.path"/> </target> <target name="load.property"> <property name="module.home" value="${basedir}"/> <!-- module/src --> <property name="src.dir" value="${basedir}/src"/> </target> <!-- ***********************编译业务模块*************************--> <target name="compile" depends="setup.classpath"> <ant antfile="${basedir}/build.xml" dir="${project.javacode}/public" target="compile.module"/> <ant antfile="${basedir}/build.xml" dir="${project.javacode}/xtgl" target="compile.module"/> <ant antfile="${basedir}/build.xml" dir="${project.javacode}/workflow" target="compile.module"/> <ant antfile="${basedir}/build.xml" dir="${project.javacode}/jj" target="compile.module"/> <ant antfile="${basedir}/build.xml" dir="${project.javacode}/bsd" target="compile.module"/> <ant antfile="${basedir}/build.xml" dir="${project.javacode}/yjfx" target="compile.module"/> </target> <!-- ***********************编译代码*************************--> <target name="compile.module" depends="load.property" description="building ${module.home}"> <echo>+--------------------------------------------------------+</echo> <echo message="+ Building : all files"/> <echo message="+ Module : ${module.home}"/> <echo>+--------------------------------------------------------+</echo> <javac debug="${javac.debug}" encoding="${javac.encoding}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" source="1.6" destdir="${build.classes}" failonerror="true"> <src path="${src.dir}"/> <include name="**/**/**/***.java"/> <exclude name="**/**/test/**/***.java"/> <classpath> <pathelement path="${build.classes}"/> <pathelement path="${build.classpath}"/> </classpath> </javac> <copy todir="${build.classes}" overwrite="true"> <fileset dir="${src.dir}" > <include name="**/**/**/***.*"/> <exclude name="**/.svn/**"/> <exclude name="**/**/**/***.java"/> </fileset> </copy> </target> <target name="copy"> <copy todir="${project.webapp}/WEB-INF/classes" overwrite="true"> <fileset dir="${build.target}/classes"> <include name="**/**/**/***.*"/> <exclude name="**/.svn/**"/> </fileset> </copy> </target> <!-- ***********************组装*************************--> <target name="assembly" depends="setup.classpath"> <war destfile="${build.archive}/jjpt.war" webxml="${project.webapp}/WEB-INF/web.xml"> <lib dir="${project.lib}"/> <fileset dir="${project.webapp}" > <include name="**/**/***.*"/> <exclude name="**/**/.svn/**/**"/> <exclude name="WEB-INF/classes/**"/> </fileset> <classes dir="${project.root}/src"> <exclude name=".svn"/> <include name="*.*"/> <exclude name="datasource.xml"/> </classes> <classes dir="${build.target}/classes"> <include name="**/**/**/***.*"/> <exclude name="datasource.xml"/> </classes> <webinf dir="${project.webapp}/WEB-INF"> <include name="taglib/**/**"/> <exclude name="**/**/.svn/**/**"/> </webinf> </war> </target> <!-- ***********************上传*************************--> <target name="upload"> <scp file="${build.archive}/jjpt.war" todir="root:qwe123@10.2.31.235:/opt/deploy/jjpt" trust="true"/> </target> <!-- ***********************开发环境部署*************************--> <target name="deploy"> <sshexec host="10.2.31.235" username="root" password="qwe123" trust="true" command="/opt/TongWeb5.0/bin/antdeploy.sh"/> </target> <!--打包成.zip夹包--> <target name="zip"> <zip destfile="${build.archive}/webapp.zip" basedir="${project.webapp}" /> </target> </project>
linux 脚本
export PATH="/programFiles/jdk1.6.0_43/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" export JAVA_HOME="/programFiles/jdk1.6.0_43" export TWHOMEDIR="/root/TongWeb5.0" /root/TongWeb5.0/bin/stopserver.sh cd /root/app/jjpt rm -rf WEB-INF sleep 60 jar -xvf jjpt.war nohup /root/TongWeb5.0/bin/startserver.sh >/dev/null 2>&1 &