ANT 패키지 명령

6012 단어 ant
다음 코드 는 한 프로젝트 의 포장 을 바탕 으로 DOC API 문 서 를 생 성하 고 발표 하 는 등 일부 과정 입 니 다. 개발 자 에 게 편 의 를 제공 합 니 다.
 
코드 는 다음 과 같 습 니 다:
<?xml version="1.0" encoding="GB2312"?>
<!--    dist  ,basedir="."      -->
<project default="dist" basedir=".">
	<!--         -->
	<property environment = "env" /><!--  widow,unix     -->
	<property name="java.home" value="${env.JAVA_HOME}"/><!--        Java_home    .-->
	<property name="ant.home"  value="${env.ANT_HOME}"/> <!--        Ant_home   -->
	
	<!--     app         -->
	<property name="app.name" value="HelloWorld"/>
	<property name="app.jar" value= "${app.name}.jar"/>
	<property name="app.copyright" value="Copyright(c)2011 sz All right reserved."
		
	<!--app    src   -->	
	<property name="src.dir" value="src"/>
	<property name="src.main" value="${src.dir}/main"/>
	<property name="src.script" value="${src.dir}/script"/>
	
	<!--app   lib-->
	<property name="lib.dir" value="lib"/>
	
	<!--app build   -->
	<property name="build.dir" value="build"/>
	<property name="build.classes" value="${build.dir}/classes"/>
	<property name="build.docs" value="${build.dir}/docs"/>
	<property name="build.docs.api" value="${build.docs}/api"/>
	<property name="build.lib" value="${build.dir}/lib" />
	
	<!--app dist(distribution)     .   -->
	<property name="dist.dir" value="dist"/>
	<property name="dist.bin" value="${dist.dir}/bin"/>
	<property name="dist.docs" value="${dist.dir}/docs"/>
	<property name="dist.lib" value="${dist.dir}/lib"/>
	
	<!--app docs   -->
	<property name="docs.dir" value="docs"/>
	<!--  classpath  -->
	<path id="classpath">
		<!--      -->
		<pathelement location="${build.classes}"/>
		<!--  java home     -->
		<pathelement path="${java.home}/lib/tools.jar"/>
	<path>
	
	<!--     ,     -->
	<target name="init">
			<!--      ,failonerror,    ,     ,     ,
			 false      。      ,     true,         -->
			<delete dir="${build.dir}" failonerror="false"/>
			<delete dir="${dist.dir}" failonerror="false"/>
			
			<!--    ,      -->
			<mkdir dir="${build.dir}" />
			<mkdir dir="${build.classes}"/>
			<mkdir dir="${build.docs}"/>
			<mkdir dir="${build.docs.api}"/>
			<mkdir dir="${build.lib}"/>
			<mkdir dir="${dist.dir}"/>
			<mkdir dir="${dist.bin}"/>
			<mkdir dir="${dist.lib}"/>
	</target>
	
	<!--inti       ,  build       ,    inti     -->
	<!--    -->
	<target name="build" depends="init">
		  <!--srcdir   .java     ,destdir   ,    class  ,     ,-->
			<javac srcdir="${src.main}" destdir="${build.classes}">
				<!--  classpath   ,  java home/lib/tools.jar  ,    .-->
				<classpath refid="classpath"/>
			<javac>
	</target>		
	
	<!--    ,   build  -->	
	<target name="jars" depends="build">
			 <!--basedir   , build/classes    .class      ,-->
			 <!--jarfile   ,jar      ,  jar ,war(web    war 。)${app.jar}   ,      HelloWorld.jar-->
			 <jar basedir="${build.classes}" jarfile="${build.lib}/${app.jar}"/>
	</target>
	
	<!--  doc    ,          -->
	<target name="javadocs" depends="jars" description=" Create The API documentation">
		<!--copy docs  ,todir   ,           ,-->
		<copy todir="${build.docs}">
			<!--     ,   dir      -->
			<fileset dir="${docs.dir}"/>
		</copy>
		
		<!--packagenames,     -->
		<javadoc packagenames="hello.ant.*" 
			sourcepath="${src.main}"
			defaulttextcudes="yes"
			destdir="${build.docs.api}"
			ahthor="true"
			version="true"
			use="true"
			windowtitle="Docs API">
			<doctitle>
					<![CDATA[<h1>Hello World Ant Docs API</h1>]]</doctitle>
					<!--API  ,        ,-->
					<buttom><![CDATA[<i>${app.copyright}</i>]]></buttom>
					<tag name="todo" scope="all" description="To do:"/>
		</javadoc>		
	</target>
	
  <!--    ,   javadocs-->
  <target name="dist" depends="javadocs">
  	 <!--  bin    -->
  	 <copy todir="${dist.bin}">
  	 		<fileset dir="${src.script}"/>
  	 </copy>
  	 
  	 <copy todir="${dist.docs}">
  	 		<fileset dir="${build.docs}"/>
  	 </copy>
  	 
  	 <copy todir="${dist.lib}">
  	 		<fileset dir="${build.lib}"/>
  	 </copy>	
  </target>	
</project>	

좋은 웹페이지 즐겨찾기