ant instance

<?xml version="1.0" encoding="UTF-8"?>
<project name="Nightingale" default="" basedir=".">
	<target name="init">
		<echo message="Initialize the path variable required for the war package"/>
		<!--Get system time-->
		<tstamp>
			<format property="sys.time" pattern="yyyy-MM-dd_HH-mm-ss"></format>
		</tstamp>
		<!--Read build.properies file-->
		<property file="${basedir}/build.properties"/>
		<!--Configure the java compilation environment-->
		<path id="Nightingale.compile.classpath">
			<fileset dir="${weblib.dir}">
				<include name="**/*.jar" />
			</fileset>
			<fileset dir="${builder.basedir.j2ee}">
				<include name="**/*.jar" />
			</fileset>
		</path>
		<!--Determine whether there is a file under the conf folder-->
		<available file="${publish.conf}" property="keyfile.exist" />
	</target>
	
	<!--Delete the publish folder and delete the war package-->
	<target name="clean" depends= "init">
		<echo message="Empty source files"/>
		<delete dir="${publish.dir}" />
		<delete><fileset dir="${builder.basedir}" includes="**/*.war"/></delete>
	</target>
	
	<!--Create publish folder-->
	<target name="prepare" depends= "clean">
		<echo message="Create folder"/>
		<mkdir dir="${publish.dir}"/>
	</target>
	
	<!-- Copy the webRoot file in the function directory to publish, and compile the java file-->
	<target name="build-copy" depends="prepare">
		<echo message="Copy the webRoot file to the compiled path"/>
		<copy todir="${publish.dir}">
			<fileset dir="${webapp.dir}"/>
		</copy>
		<echo message="Compile the java file, copy the attribute configuration file to the compiled path"/>
		<javac destdir="${publish.classes}">
			<src path="${java.src.dir}" />
			<classpath refid="Nightingale.compile.classpath" />
		</javac>
	</target>
	
	<!-- Copy the files in the conf directory to publish-->
	<target name="conf.exist" if="${keyfile.exist}">
		<echo message="Copy the files in the conf file directory to the project conf directory --${publish.conf}"/>
		<copy todir="${publish.web.conf}" overwrite = "true" verbose="true">
			<fileset dir="${publish.conf}"/>
		</copy>
	</target>
	<target name="conf.unexist" unless="${keyfile.exist}">
		<echo message="The file does not exist in the ${publish.conf} folder"/>
	</target>
	
	<!--Pack the files in publish into war files-->
	<target name="publish-war" depends="build-copy,conf.exist,conf.unexist">
		<echo message="Open the war package, do not enter the java file into the package"/>
		<war warfile="${war.file}" webxml="${publish.web}">
			<fileset dir="${publish.dir}" />
		</war>
	</target>
	
	<!-- Copy the war package to the server-->
	<target name="publish-remote">
		<antcall target="publish-war" />
		<echo>Send file ${war.file} to server...</echo>
		<scp file="${war.file}" todir="${publish.remote.username}:${publish.remote.password}@${publish.remote.host}:${publish.remote.apphome}"  passphrase="" verbose="true" trust="true"/>
	</target>
</project>



java.src.dir = ${basedir}/src
webapp.dir = $ {basedir} / WebRoot
weblib.dir = $ {webapp.dir} / WEB-INF / lib /
builder.basedir = ${basedir}/build
builder.basedir.j2ee = ${builder.basedir}/lib/

<!-- Directory structure of the project -->
publish.dir = ${builder.basedir}/publish
publish.web = ${publish.dir}/WEB-INF/web.xml
publish.classes = ${publish.dir}/WEB-INF/classes
publish.web.conf = ${publish.classes}/conf
publish.conf = ${builder.basedir}/conf
war.file = ${builder.basedir}/Nightingale_${sys.time}.war

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326805151&siteId=291194637
ANT
ANT