ant build.xml

<?xml version="1.0"?>
<project name="janson" basedir="." default="war">
	<property environment='env'/>

	<property name="app.name" 			value="framework30"  />
	<property name="framework30.dir" 	value="${basedir}/framework30" />
	<property name="src.dir" 			value="${basedir}/src" />
	<property name="conf.dir" 			value="${basedir}/conf" />
	<property name="war.dir" 			value="${basedir}/WebRoot" />
	<property name="lib.dir" 			value="${war.dir}/WEB-INF/lib" />
	<property name="work.dir"	 		value="D:/workspace/build/${app.name}" />
	<property name="target.dir"	 		value="${work.dir}/build" />
	<property name="dist.dir"	 		value="${work.dir}/dist"  />
	<property name="deploy.dir"	 		value="${basedir}/server" />

	<path id="all-libs">
		<fileset dir="${lib.dir}">
			<include name="**/*.jar"/>
		</fileset>
	</path>	

	<target name="clean" description="Clean output dirs">
		<delete dir="${target.dir}"/>
		<delete dir="${dist.dir}"/>
	</target>

	<target name="build" description="Compile main java sources">
		<mkdir dir="${target.dir}"/>

		<javac destdir="${target.dir}" encoding="utf-8" compiler="javac1.5" source="5" target="5" debug="true" deprecation="true" optimize="true" failonerror="true">
			<src path="${src.dir}"/>
			<src path="${framework30.dir}"/>
			<classpath refid="all-libs"/>
		</javac>
	
		<!-- copy other none java files such as hibernate hbm.xml files -->
		<copy todir="${target.dir}" preservelastmodified="true">
			<fileset dir="${src.dir}">
				<exclude name="**/*.java"/>
			</fileset>
		</copy>		
		
		<!-- copy other config files -->
		<copy todir="${target.dir}" preservelastmodified="true">
			<fileset dir="${conf.dir}" />
		</copy>		
	</target>
	
	<target name="jar" depends="clean, build" description="Create JAR deployment unit">
		<mkdir dir="${dist.dir}"/>
				
		<jar jarfile="${dist.dir}/${app.name}.jar">
			<fileset dir="${target.dir}" />
		</jar>
		
		<copy todir="${lib.dir}" file="${dist.dir}/${app.name}.jar" preservelastmodified="true" />
	</target>
	
	<target name="war" depends="jar" description="Create WAR deployment unit">
		<war destfile="${dist.dir}/${app.name}.war" webxml="${war.dir}/WEB-INF/web.xml">
			<fileset dir="${war.dir}" excludes="WEB-INF/**/*" />
			
			<webinf dir="${war.dir}/WEB-INF">
				<exclude name="classes/**/*.class"/>
				<exclude name="lib/**/*.*"/>
				<exclude name="web.xml"/>
			</webinf>
			
    		<lib dir="${war.dir}/WEB-INF/lib" 	includes="*.*">
    		</lib>
		</war>
	</target>

	<target name="deploy" depends="jar" description="Copy generated jar file to Deploy Project">
		<copy todir="${deploy.dir}" file="${dist.dir}/${app.name}.jar" preservelastmodified="true" />
	</target>
	
</project>

你可能感兴趣的:(java,Hibernate,xml,ant)