build.xml

积极响应公司那个特别的走路都如风的总监的要求,学习学习Ant!呵呵 一切都在后续努力中,如果大家有更好的资料,就谢谢留言告诉我哦,请多多指教!

 

<?xml version="1.0" encoding="GBK"?>
<project name="studyPro" basedir=".">
	<property name="conf.dir" value="${basedir}/conf" />
	<property name="src.dir" value="${basedir}/src" />
	<property name="classes.dir" value="${basedir}/classes" />
	<property name="jars.dir" value="${basedir}/jars" />
	<property name="web.dir" value="${basedir}/webapps" />
	<property name="bin.dir" value="${basedir}/bin" />

	<!-- <property name="jre1.5.path" value="${basedir}/jre1.5.exe" /> -->

	<property name="studyPro.studyPro.webdir" value="${basedir}/webapps/studyPro" />

	<!-- DEBUG -->
	<property name="debug.dir" value="${basedir}${file.separator}debug" />
	<property name="debug.classes.dir" value="${debug.dir}${file.separator}classes" />
	<property name="debug.conf.dir" value="${debug.dir}${file.separator}conf" />
	<property name="debug.webapps.dir" value="${debug.dir}${file.separator}webapps" />
	<property name="debug.webapps.studyPro.dir" value="${debug.dir}${file.separator}studyPro" />

	<property name="debug.server.jar" value="${debug.dir}${file.separator}StudyPro.jar" />
	<property name="debug.web.war" value="${debug.webapps.dir}${file.separator}studyPro.war" />
	<property name="debug.web.root.war" value="${debug.webapps.dir}${file.separator}ROOT.war" />

	<!-- RELEASE -->
	<property name="deploy.dir" value="${basedir}${file.separator}release" />

	<path id="project.class.path">
		<fileset dir="${jars.dir}">
			<include name="**/*.jar" />
		</fileset>
		<pathelement path="${classes.dir}" />
	</path>

	<target name="copyBaseFile">
		<echo level="info">拷贝必要的文件到${debug.dir}下</echo>
		<copy todir="${debug.dir}">
			<fileset dir="${basedir}">
				<include name="jars/*/**" />
				<include name="conf/*/**" />
				<include name="database/*.sql" />
				<include name="documents/*/**" />
				<include name="*.properties" />
				<include name="*.jar" />
				<include name="*.bat" />
				<include name="*.sh" />
				<exclude name="*/build.properties" />
			</fileset>
		</copy>
	</target>

	<target name="war-StudyPro" description="create Numen Web App File">
		<echo level="info">打包StudyPro-Web</echo>
		<war destfile="${debug.web.war}" webxml="${web.dir}/studyPro/WEB-INF/web.xml">
			<fileset dir="${web.dir}/studyPro">
				<exclude name="**/CVS" />
				<exclude name="**/cvs" />
				<exclude name="**/.svn/**" />
				<exclude name="**/*.log" />
				<exclude name="**/*.bak" />
				<exclude name="**/*.bak/**" />
				<exclude name="**/.**" />
				<exclude name="**/WEB-INF/classes/**" />
				<exclude name="**/WEB-INF/lib/**" />
			</fileset>
		</war>
	</target>

	<target name="war-ROOT" description="create ROOT App File">
		<echo level="info">打包root</echo>
		<war destfile="${debug.web.root.war}" webxml="${web.dir}/ROOT/WEB-INF/web.xml">
			<fileset dir="${web.dir}/ROOT">
				<exclude name="**/CVS" />
				<exclude name="**/cvs" />
				<exclude name="**/.svn/**" />
				<exclude name="**/*.log" />
				<exclude name="**/*.bak" />
				<exclude name="**/*.bak/**" />
				<exclude name="**/.**" />
				<exclude name="**/WEB-INF/classes/**" />
				<exclude name="**/WEB-INF/lib/**" />
			</fileset>
		</war>
	</target>

	<target name="deploy-studyPro">
		<echo level="info">拷贝StudyPro文件到调试目录</echo>
		<copy todir="${debug.webapps.studyPro.dir}">
			<fileset dir="${studyPro.studyPro.webdir}">
				<include name="*/**" />
			</fileset>
		</copy>
		<antcall target="copyBaseFile" />
	</target>

	<!-- 初始化DEBUG -->
	<target name="debug-init">
		<echo level="info">初始化调试目录,清除${debug.dir}下所有文件</echo>
		<delete includeemptydirs="true" failonerror="off">
			<fileset dir="${debug.dir}">
				<include name="*/**" />
			</fileset>
		</delete>
		<echo level="info">创建${debug.dir}目录</echo>
		<mkdir dir="${debug.dir}" />
		<echo level="info">创建${debug.webapps.dir}目录</echo>
		<mkdir dir="${debug.webapps.dir}" />
		<mkdir dir="${debug.dir}/logs" />
		<antcall target="war-StudyPro" />
		<antcall target="war-ROOT" />
		<antcall target="deploy-studyPro" />
	</target>

	<target name="compile-src" description="compile the source ">
		<echo>+---------------------------------------------------+</echo>
		<echo>| |</echo>
		<echo>| C O M P I L E U M P R O J E C T |</echo>
		<echo>| |</echo>
		<echo>+---------------------------------------------------+</echo>

		<mkdir dir="${classes.dir}" />

		<javac srcdir="${src.dir}" destdir="${classes.dir}" source="1.5" memorymaximumsize="256m" fork="true">
			<classpath refid="project.class.path" />
		</javac>

		<copy todir="${classes.dir}">
			<fileset dir="${src.dir}">
				<exclude name="**/*.java" />
				<exclude name="**/CVS" />
				<exclude name="**/cvs" />
				<exclude name="**/.svn/**" />
				<exclude name="**/*.log" />
				<exclude name="**/*.bak" />
				<exclude name="**/*.bak/**" />
				<exclude name="**/.**" />
			</fileset>
		</copy>
	</target>

	<target name="jar-StudyPro" depends="compile-src" description="create StudyPro.jar File">
		<echo level="info">打包StudyPro.jar</echo>
		<jar destfile="${debug.server.jar}">
			<fileset dir="${classes.dir}">
				<exclude name="**/CVS" />
				<exclude name="**/cvs" />
				<exclude name="**/*.log" />
				<exclude name="package*/**" />
				<exclude name="jsp*/**" />
				<exclude name="cache*/**" />
				<exclude name="Generated*/**" />
				<exclude name="**/.**" />
			</fileset>
		</jar>
	</target>

	<target name="clean-web">
		<echo level="info">仅保留war文件,其他文件都清除</echo>
		<delete includeemptydirs="true">
			<fileset dir="${debug.webapps.dir}">
				<include name="studyPro/*/**" />
				<include name="*" />
				<exclude name="*.war" />
			</fileset>
		</delete>
	</target>

	<target name="release" depends="clean-web">
		<echo level="info">初始化发布目录,清除${deploy.dir}下所有文件</echo>
		<delete includeemptydirs="true" failonerror="off">
			<fileset dir="${deploy.dir}">
				<include name="*/**" />
			</fileset>
		</delete>
		<echo level="info">拷贝文件到发布目录</echo>
		<copydir dest="${deploy.dir}" src="${debug.dir}" forceoverwrite="true" excludes="${debug.webapps.dir}/deploy" />


		<!--<echo level="info">拷贝JRE1.5到发布目录</echo>
		<copy todir="${deploy.dir}" file="${jre1.5.path}" />-->

	</target>

	<target name="default" depends="debug-init,jar-StudyPro,war-StudyPro,release" />
</project>

 

你可能感兴趣的:(Web,xml,ant,SVN,cvs)