我常用的ANT—build.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project name="C03" basedir=".">

	<condition property="server.exte" value=".bat">
		<os family="windows" />
	</condition>
	<condition property="server.exte" value=".sh">
		<os family="unix" />
	</condition>

	<property name="project.root.dir" value="./.." />
	<property name="project.webRoot.dir" value="${project.root.dir}/WebRoot" />
	<property name="project.src.dir" value="${project.root.dir}/src" />
	<property name="project.web-inf.dir" value="${project.webRoot.dir}/WEB-INF" />
	<property name="project.class.path.dir" value="${project.web-inf.dir}/classes" />

	<property name="dist.dir" value="dist" />

	<property name="tomcat.home" value="F:/Program Files/apache-tomcat-6.0.0" />


	<property name="client.request.host" value="localhost" />
	<property name="client.request.port" value="8080" />
	<property name="server.charset" value="UTF-8" />
	<property name="result" value="./result" />
	<property name="client.dir" location="./client" />
	<property name="client.src" value="${client.dir}/src" />
	<property name="client.class.path" value="${client.dir}/classes" />
	<property name="client.response" location="${result}/response.html" />

	<target name="client.compile">
		<javac srcdir="${client.src}" destdir="${client.class.path}" />
	</target>

	<target name="client.request" depends="client.compile">
		<java classname="SendMessageTool" dir="${client.class.path}" fork="true" output="${result}/output.log" error="${result}/error.log">
			<arg value="${ant.project.name}" />
			<arg value="${client.dir}/message.xml" />
			<arg value="${client.request.host}:${client.request.port}" />
			<arg value="${client.response}" />
			<arg value="${server.charset}" />
		</java>
	</target>

	<target name="clear">
		<delete dir="${dist.dir}" />
		<delete file="${tomcat.home}\webapps\${ant.project.name}.war" />
		<delete dir="${tomcat.home}\webapps\${ant.project.name}" />
	</target>

	<target name="compile">
		<javac srcdir="${project.src.dir}" destdir="${project.class.path.dir}">
			<classpath>
				<fileset dir="${project.web-inf.dir}/lib">
					<include name="*.jar" />
				</fileset>
			</classpath>
		</javac>
		<copydir src="${project.src.dir}" dest="${project.class.path.dir}" >
			<include name="**/*.xml" />
			<include name="**/*.properties" />
		</copydir>
	</target>

	<target name="dist">
		<mkdir dir="${dist.dir}" />
		<war destfile="${dist.dir}/${ant.project.name}.war" basedir="${project.webRoot.dir}" webxml="${project.web-inf.dir}/web.xml" />
	</target>

	<target name="deploy" depends="clear,dist" description="deploy">
		<copy file="${dist.dir}/${ant.project.name}.war" todir="${tomcat.home}\webapps" />
	</target>

	<target name="start.cat" depends="deploy">
		<exec command="${tomcat.home}/bin/startup${server.exte}">
			<env key="CATALINA_HOME" value="${tomcat.home}" />
		</exec>
	</target>

	<target name="stop.cat">
		<exec command="${tomcat.home}/bin/shutdown${server.exte}">
			<env key="CATALINA_HOME" value="${tomcat.home}" />
		</exec>
		
		<antcall target="clear"/>
	</target>
	
	
	
	<target name="start.cat.only">
		<exec command="${tomcat.home}/bin/startup${server.exte}">
			<env key="CATALINA_HOME" value="${tomcat.home}" />
		</exec>
	</target>

	
	
	
	<target name="re_deploy">
		<antcall target="clear" />
		<antcall target="deploy" />
	</target>

	<target name="echo">
		<echo>${tomcat.home}</echo>
		<echo>${webRoot.dir}</echo>
		<echo>${ant.project.name}</echo>
		<echo>${pre.project.name}</echo>
	</target>
</project>

 

你可能感兴趣的:(tomcat,xml,Web,ant,OS)