xml 代码
- <project name="app" default="all" basedir=".">
- <property file="${basedir}/build.properties" />
- <!-- set global properties for this build -->
- <property name="app.project.root" value="kmss_hr_pm" />
- <property name="app.project.name" value="kpi" />
- <property name="app.src"
- value="${app.project.name}/${app.project.root}/src" />
- <property name="app.web"
- value="${app.project.name}/${app.project.root}/WebContent" />
- <property name="build" value="${app.web}/WEB-INF/classes" />
- <property name="dist" value="dist" />
- <property name="cvsroot"
- value=":pserver:${cvs.user}:${cvs.password}@${cvs.server}:${cvs.repository}" />
- <property name="main.dir" value="${app.project.name}" />
- <property name="main.cvs.repository.path"
- value="${app.project.root}" />
- <property name="tomcat.home"
- value="D:/Apache Software Foundation/Tomcat 5.0" />
- <!--
- Initializing -->
- <target name="init">
- <tstamp>
- <format property="today" pattern="yyyy-MM-dd hh:mm:ss" />
- </tstamp>
- <echo message="${today}" />
- <echo message="*****************************************" />
- <echo message=" --应用程序自动发布-- " />
- <echo message=" 系统将自动运行以下任务: " />
- <echo message=" 1.从cvs下载源代码 " />
- <echo message=" 2.编译下载的源代码 " />
- <echo message=" 3.停止tomcat程序运行 " />
- <echo message=" 4.将编译好的应用程序打包 " />
- <echo message=" 5.发布应用程序到tomcat应用服务器 " />
- <echo message=" 6.启动tomcat应用服务器 " />
- <echo message="******************************************" />
- <sleep seconds="5"/>
- </target>
- <target name="all" depends="init,clean,main-check-out,compile,dist,deploy">
- </target>
- <!-- 捡出主干程序 -->
- <target name="main-check-out">
- <echo message="正在捡出程序..." />
- <cvs cvsRoot="${cvsroot}" package="${main.cvs.repository.path}"
- dest="${main.dir}" />
- </target>
- <target name="compile">
- <!-- Compile the java code from ${src} into ${build} -->
- <echo message="正在编译应用程序..." />
- <delete dir="${build}" />
- <mkdir dir="${build}" />
- <echo message="build src:${app.src}\ndestdir:${build}" />
- <javac srcdir="${app.src}" destdir="${build}" encoding="UTF-8"
- source="1.4" fork="true" memoryMaximumSize="512M">
- <classpath>
- <fileset dir="${basedir}">
- <include name="${app.web}/WEB-INF/lib/*.jar" />
- <include name="lib/*.jar" />
- </fileset>
- <pathelement path="${java.class.path}/" />
- </classpath>
- </javac>
- <copy toDir="${build}">
- <fileset dir="${app.src}"
- includes="**/*.properties,**/*.xml" />
- </copy>
- </target>
- <target name="dist">
- <echo message="正在构建程序到${dist}目录..." />
- <mkdir dir="${dist}" />
- <copy todir="${dist}">
- <fileset dir="${app.web}" />
- </copy>
- </target>
- <target name="clean">
- <echo message="正在清除${dist}中的历史构建..." />
- <delete dir="${dist}" />
- <delete dir="${app.project.root}" />
- </target>
- <target name="deploy"
- depends="stop-tomcat,delete-old-work,create-war-file,start-tomcat" >
- <echo message="发布应用程序完毕." />
- </target>
- <target name="start-tomcat">
- <echo message="正在启动tomcat..." />
- <exec dir="${tomcat.home}/bin"
- executable="${tomcat.home}/bin/startup.bat"
- spawn="true">
- </exec>
- </target>
- <target name="stop-tomcat">
- <echo message="正在停止tomcat..." />
- <exec dir="${tomcat.home}/bin"
- executable="${tomcat.home}/bin/shutdown.bat">
- </exec>
- <sleep seconds="6"/>
- </target>
- <target name="delete-old-work">
- <echo message="正在清除tomcat中的历史发布..." />
- <delete dir="${tomcat.home}/work/Catalina/localhost" failonerror="false"/>
- <delete dir="${tomcat.home}/webapps/kpi" failonerror="false"/>
- <delete file="${tomcat.home}/webapps/kpi.war" failonerror="false"/>
- </target>
- <target name="create-war-file">
- <echo message="正在打包应用程序..." />
- <war destfile="${tomcat.home}/webapps/kpi.war"
- basedir="${dist}" webxml="${dist}/WEB-INF/web.xml">
- </war>
- </target>
- </project>