`
greenwen
  • 浏览: 220465 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论
阅读更多
<project name="hnwt114" default="build" basedir=".">
	<!-- 工程根目录 -->
	<property name="hnwt144.home" value="."/>
	<!-- 工程根名 -->
	<property name="hnwt144.name" value="HNWT114"/>
	<!-- tomcat路径 -->
	<property name="tomcat.home" value="D:\apache-tomcat-5.5.26"/>
	<!-- tomcat部署路径 -->
	<property name="webapps.home" value="${tomcat.home}/webapps"/>
	<!-- JAVA源文件路径 -->
	<property name="src.home" value="${hnwt144.home}/src"/>
	
	<!-- class文件存放位置 -->
	<property name="classes.home" value="${hnwt144.home}/classes"/>
	<!-- 发布文件夹 -->
	<property name="deploy.home" value="${hnwt144.home}/deploy"/>
	<!-- webRoot路径 -->
	<property name="web.home" value="${hnwt144.home}/webRoot"/>
	
	<!-- 创建工程路径 -->
	<property name="build.home" value="${hnwt144.home}/build"/>
	<!-- /WEB-INF/classes -->
	<property name="build.classes" value="${hnwt144.home}/WEB-INF/classes"/>
	<!-- /WEB-INF/lib -->
	<property name="build.lib" value="${hnwt144.home}/WEB-INF/lib"/>
	<!-- 工程引用包 -->
	<property name="lib.home" value="${web.home}/WEB-INF/lib"/>
	
	
	<!-- 编译工程所需的JAR包 -->
	<path id="compile.classpath">
		<pathelement location="${classes.home}"/>
		<fileset dir="${lib.home}">
				<include name="*.jar"/>
				<include name="*.zip"/>
		</fileset>
		<fileset dir="${tomcat.home}/common/lib">
			<include name="*.jar"/>
		</fileset>
		<pathelement location="${tomcat.home}/common/classes"/>
	</path>
	
	
	<!-- 测试ANT -->
	<target name="help">
		<echo message="Please specify a target![usage:ant&lt;targetname&gt;]"/>
		<echo message="Here is a list of possible targets:"/>
		<echo message="  clean-all....Delete build dir,all .class and war files"/>
		<echo message="  perpare....Creates directories if requied"/>
		<echo message="  compile....Compiles source files"/>
		<echo message="  build......Build war file from.class and other files"/>
		<echo message="  deploy......Copy war file to the webapps directory"/>
	</target>
	
	
	<!-- 清除 -->
	<target name="clean-all">
		<delete dir="${build.home}"/>
		<delete dir="${classes.home}"/>
		<delete dir="${deploy.home}"/>
		
		<delete dir="${webapps.home}/${hnwt114.home}" failonerror="false"/>
		<delete dir="${webapps.home}/${hnwt114.name}.war"/>
	</target>
	
	
	<!-- 准备工作 -->
	<target name="prepare">
		<echo message="Tomcat Home=${tomcat.home}"/>
		<echo message="Webapps Home=${webapps.home}"/>
		
		<mkdir dir="${classes.home}"/>
		<mkdir dir="${deploy.home}"/>		
		
		<mkdir dir="${build.home}"/>
		<mkdir dir="${build.home}/WEB-INF"/>
		<mkdir dir="${build.home}/WEB-INF/classes"/>
		<mkdir dir="${build.home}/WEB-INF/lib"/>
	</target>
	
	
	<!-- 编译 -->
	<target name="compile" depends="prepare">
		<javac srcdir="${src.home}" destdir="${classes.home}" debug="no">
			<classpath refid="compile.classpath"/>
		</javac>
	</target>
	
	<!-- 构建临时工程 -->
	<target name="build" depends="compile">
		<copy todir="${build.home}">
			<fileset dir="${web.home}"/>
		</copy>
		<copy todir="${build.home}/WEB-INF/classes">
			<fileset dir="${classes.home}"/>
		</copy>
		
		<copy todir="${build.home}/WEB-INF/classes">
			<fileset dir="${src.home}">
				<include name="**/*.properties"/>
				<include name="**/*.prop"/>
			</fileset>
		</copy>
		
		<jar jarfile="${deploy.home}/${hnwt144.name}.war" basedir="${build.home}"/>
	</target>
	<!-- 发布 -->
	<target name="deploy" depends="build">
		<copy todir="${webapps.home}" file="${deploy.home}/${hnwt144.name}.war"/>
	</target>
		
	</project>


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics