ant 컴 파일 패키지 학습 노트

2680 단어 ant 컴 파일
ant 를 사용 하여 웹 프로젝트 를 포장 하고 ant 명령 으로 ant 소프트웨어 를 미리 설치 하 며 설정 하 는 것 을 배 웠 습 니 다.
환경 변수:
ANT_HOME = ant 설치 목록   
PATH=%PATH%;%ANT_HOME%/bin
http://blog.csdn.net/lip009/article/details/1226931 에 따라 build. xml 파일 을 스스로 썼 습 니 다.
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntTest" basedir="." default="war">
	<description>
			This is a  description for AntTest
	</description>
	<!--        -->
	<property name="webroot" location="WebRoot"></property>
	<property name="classes.dir" location="${webroot}/WEB-INF/classes"></property>
	<property name="lib.dir" location="${webroot}/WEB-INF/lib"></property>
	<property name="dist.dir" location="dist"></property>
	<property name="config.dir" location="config"></property>
	
	<path id="classpath">
			<fileset dir="${classes.dir}"></fileset>
			<fileset dir="${lib.dir}"></fileset>
		</path>
	
	<target name="init-dir" >
		<mkdir dir="${classes.dir}"/>	
		<mkdir dir="${lib.dir}"/>
		<mkdir dir="${dist.dir}"/>
		<echo>    ,  .</echo>
	</target>	
	
	<target  name="src-compile">
		<javac target="1.6" srcdir="src" destdir="${classes.dir}"  classpathref="classpath" includeantruntime="false"> 
			<!--       ,        -->
			<compilerarg line="-encoding UTF-8"/>
		</javac>
		<echo>    ,  .</echo>
	</target>
	
	<target name="copy-config">
		<copy todir="${classes.dir}">
			<fileset dir="${config.dir}" includes="**/*.*"></fileset>
		</copy>
		<echo>       classes ,  .</echo>
	</target>
	
	<target name="war"  depends="init-dir,src-compile,copy-config">
		<war destfile="${dist.dir}/${ant.project.name}.war" basedir="${webroot}"></war>
		<echo>  War ,  .</echo>
	</target>

</project>
이것 은 가장 간단 한 built. xml 일 뿐 입 니 다. jar 가방 을 치 려 면 안에 추가 할 수 있 습 니 다.

좋은 웹페이지 즐겨찾기