ant使用基础笔记

  ant是主要用于java平台的一个编译工具。可以为Java工程指定一系列的编译、打包、运行、部署命令。build.xml的格式一般如下:

<project name="olympics" default="run">

	<property name="lib_path" value="lib"/>
	<property name="jar_name" value="cs3051.jar"/>
	<property name="jar_opencsv" value="opencsv-2.3.jar"/>
	<property name="dest_dir" value="build/classes"/>
	<property name="src_dir" value="src"/>
	<property name="man_class" value="cs5031.cw1.olympics.OlympicsMedalTable"/>
	
	<!-- retrieve the OpenCSV library and put it into the lib_path -->
	<target name="retrieve">
		<mkdir dir="${lib_path}"/>
		<get src="http://repo1.maven.org/maven2/net/sf/opencsv/opencsv/2.3/opencsv-2.3.jar" dest="${lib_path}"/>
	</target>
	<target name="init">
		<mkdir dir="${dest_dir}"/>
	</target>
	<target name="compile" depends="init" >
		 <javac srcdir="${src_dir}" destdir="${dest_dir}" classpath="${lib_path}/${jar_opencsv}"/>
	</target>
	
	<target name="build" depends="compile">
		<jar jarfile="${jar_name}" basedir="${dest_dir}"/>
	</target>
	<target name="run" depends="build">
		<java classname="${man_class}" classpath="${jar_name}:${lib_path}/${jar_opencsv};."/>
	</target>

</project>

你可能感兴趣的:(ant)