ant学习笔记2

  • ant简明教程,其中包括if,unless,copy,move,delete,mkdir,echo,property,javac,jar,war(使用war命令打包JavaEE项目 )实现命令的介绍。
  • ant的常见数据类型,其中涉及到的有:
    	<arg/>
    	<env/>
    	<filelist/>
    	<fileset/>
    	<patternset></patternset>
    	<filterset/>
    	<path></path>
    	<mapper></mapper>
    

 其他的数据类型包含在org.apache.tool.ant.types包中

  • 而在hadoop的build.xml中还差的命令有如下:,要想知道其中的含义,需查看ant的各种默认命令,或者官网doc。以下是我将要要学习的,如果有读者恰巧看到,以下就越过吧。太复杂了,我还没疏通。

 

  1.  <attribute name="Main-Class"
                          value="org/apache/hadoop/test/AllTestDriver"/>
    

     

  2.    <artifact:pom file="${hadoop-core.pom}" id="hadoop.core"/>
    

     

  3. <available file="${test.build.dir}/testsfailed" property="testsfailed"/>
    

     

  4.  <arg value="${changes.src}/changes2html.pl"/>
    

     

  5. <doclet name="jdiff.JDiff"
                   path="${jdiff.jar}:${xerces.jar}">
             <param name="-apidir" value="${jdiff.xml.dir}"/>
             <param name="-apiname" value="hadoop ${version}"/>
           </doclet>
    

     

  6. <batchtest todir="@{test.dir}" if="tests.notestcase">
     <fileset dir="@{fileset.dir}"
                       excludes="**/${test.exclude}.java aop/** system/**">
                <
    patternset>
                  <includesfile name="@{test.file}"/>
                </patternset>
                <patternset refid="@{exclude.list.id}"/>
              </fileset>
            </batchtest>

     

  7.  <chmod perm="ugo+x" type="file" parallel="false">
            <fileset dir="${dist.dir}/bin"/>
            <fileset dir="${dist.dir}/sbin"/>
            <fileset dir="${dist.dir}/src/contrib/">
              <include name="*/bin/*" />
            </fileset>
            <fileset dir="${dist.dir}/src/contrib/ec2/bin/image"/>
        </chmod>
    

     

  8.  <clover-report>
         <current outfile="${clover.report.dir}" title="${final.name}">
         <format type="html"/>
         </current>
      </clover-report>
    

     

  9.   	<checkstyle config="${test.src.dir}/checkstyle.xml"
      		failOnViolation="false">
          <fileset dir="${core.src.dir}" includes="**/*.java" excludes="**/generated/**"/>
          <fileset dir="${mapred.src.dir}" includes="**/*.java" excludes="**/generated/**"/>
          <fileset dir="${hdfs.src.dir}" includes="**/*.java" excludes="**/generated/**"/>  		
          <formatter type="xml" toFile="${test.build.dir}/checkstyle-errors.xml"/>
      	</checkstyle>
    

     

  10. 	  <env key="BASE_NATIVE_LIB_DIR" value="${lib.dir}/native"/>
    

     

  11. <eclipse updatealways="true">  </eclipse>
    

     

  12. <formatter type="${test.junit.output.format}" />
    

     

  13.  <fail unless="testcase">Can't run this target without -Dtestcase setting!
        </fail>
    

     

  14.     <findbugs home="${findbugs.home}" output="xml:withMessages"
            outputFile="${findbugs.report.xmlfile}" effort="max"
            excludeFilter="${findbugs.exclude.file}" jvmargs="${findbugs.jvmargs}">
          <auxClasspath>
            <fileset dir="${lib.dir}">
              <include name="**/*.jar"/>
            </fileset>
            <fileset dir="${build.
    ivy.lib.dir}/${ant.project.name}/common"> <include name="**/*.jar"/> </fileset> </auxClasspath> <sourcePath path="${core.src.dir}"/> <sourcePath path="${mapred.src.dir}"/> <sourcePath path="${hdfs.src.dir}"/> <sourcePath path="${examples.dir}" /> <sourcePath path="${tools.src}" /> <sourcePath path="${basedir}/src/contrib/streaming/src/java" /> <class location="${build.dir}/${core.final.name}.jar" /> <class location="${build.dir}/${examples.final.name}.jar" /> <class location="${build.dir}/${tools.final.name}.jar" /> <class location="${build.dir}/contrib/streaming/${streaming.final.name}.jar" /> </findbugs>

     

  15.  <filterset>
            <filter token="PROJECT" value="${eclipse.project}"/>
          </filterset>
    

     

  16.  <get src="${jsvc.location}" dest="${jsvc.build.dir}/${jsvc.dest.name}" />
    

     

  17.     	<group title="Core" packages="org.apache.*"/>
    

     

  18. <javadoc></javadoc>
    

     

  19.   <recordcc destdir="${test.generated.dir}">
    

     

  20. <replaceregexp byline="true">
          <regexp pattern="@version"/>
          <substitution expression="${version}"/>
          <fileset dir="${basedir}/ivy">
            <include name="hadoop-core-pom.xml"/>
            <include name="hadoop-test-pom.xml"/>
            <include name="hadoop-tools-pom.xml"/>
            <include name="hadoop-examples-pom.xml"/>
            <include name="hadoop-streaming-pom.xml"/>
            <include name="hadoop-client-pom.xml"/>
            <include name="hadoop-minicluster-pom.xml"/>
          </fileset>
        </replaceregexp>
    

     

  21.  <include name="**/metrics2/*.class" />
    

     

  22.  <!--Configure Ivy by reading in the settings file
            If anyone has already read in a settings file into this settings ID, it gets priority
        -->
        <ivy:configure settingsid="${ant.project.name}.ivy.settings" file="${ivysettings.xml}" override='false'/>
    

     

  23.  <service type="org.apache.hadoop.security.token.TokenRenewer">
            <provider classname="org.apache.hadoop.hdfs.DFSClient$Renewer"/>
            <provider classname="org.apache.hadoop.mapred.JobClient$Renewer"/>
            <provider classname="org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier$Renewer"/>
            <provider classname="org.apache.hadoop.mapreduce.security.token.JobTokenIdentifier$Renewer"/>
            <provider classname="org.apache.hadoop.hdfs.HftpFileSystem$TokenManager"/>
            <provider classname="org.apache.hadoop.hdfs.web.WebHdfsFileSystem$DtRenewer"/>
          </service>
    

     

  24. <target name="test-contrib" depends="compile, compile-core-test" description="Run contrib unit tests">
        <subant target="test">
           <property name="version" value="${version}"/>
           <property name="clover.jar" value="${clover.jar}"/>
           <fileset file="${contrib.dir}/build.xml"/>
        </subant> 
      </target>
    

     

  25. <section></section>
    

     

  26.  <sign-artifact input.file="${hadoop-core.jar}" 
         output.file="${hadoop-core.jar}.asc" gpg.passphrase="${gpg.passphrase}"/>
    

     

  27. <sysproperty key="test.build.data" value="${test.build.data}" />
    

     

  28.       <sequential> </sequential>
    

     

  29.  <target name="test-core-all-withtestcaseonly" depends="jar-test" if="testcase">
        <macro-test-runner test.file="${test.all.tests.file}"
                           classpath="${test.classpath.id}"
                           test.dir="${test.build.dir}"
                           fileset.dir="${test.src.dir}"
                           test.krb5.conf="java.security.krb5.conf"
                           test.krb5.conf.filename="${test.src.dir}/krb5.conf"
                           >
        </macro-test-runner>
      </target>
    

     

  30.  <untar compression="gzip" src="${jsvc.build.dir}/${jsvc.dest.name}" dest="${jsvc.build.dir}" />
    

     

  31. 	<xslt style="${test.src.dir}/checkstyle-noframes-sorted.xsl"
            in="${test.build.dir}/checkstyle-errors.xml"
            out="${test.build.dir}/checkstyle-errors.html"/>
    

     

  32. <manifest>
            <section name="org/apache/hadoop">
              <attribute name="Implementation-Title" value="Hadoop"/>
              <attribute name="Implementation-Version" value="${version}"/>
              <attribute name="Implementation-Vendor" value="Apache"/>
            </section>
          </manifest>
    
  33. 	<javah
      	  classpath="${build.classes}"
      	  destdir="${build.native}/src/org/apache/hadoop/io/compress/zlib"
          force="yes"
      	  verbose="yes"
      	  >
      	  <class name="org.apache.hadoop.io.compress.zlib.ZlibCompressor" />
          <class name="org.apache.hadoop.io.compress.zlib.ZlibDecompressor" />
      	</javah>
    
  34.  <target name="compile-native">
        <antcall target="compile-core-native">
          <param name="compile.native" value="true"/>
        </antcall> 
      </target>
    
  35.  <jsp-compile
         uriroot="${src.webapps}/task"
         outputdir="${build.src}"
         package="org.apache.hadoop.mapred"
         webxml="${build.webapps}/task/WEB-INF/web.xml">
        </jsp-compile>
    
  36.  <taskdef name="recordcc" classname="org.apache.hadoop.record.compiler.ant.RccTask">
          <classpath refid="classpath" />
        </taskdef>
    

  37. <exec executable="sh">
           <arg line="src/saveVersion.sh ${version} ${build.dir}"/>
        </exec>
    
  38.  <tempfile property="touch.temp.file" destDir="${java.io.tmpdir}"/>
        <touch millis="0" file="${touch.temp.file}">
          <fileset dir="${conf.dir}" includes="**/*.template"/>
          <fileset dir="${contrib.dir}" includes="**/*.template"/>
        </touch>
    
  39.  <!-- ====================================================== -->
      <!-- Macro definitions                                      -->
      <!-- ====================================================== -->
      <macrodef name="macro_tar" description="Worker Macro for tar">
        <attribute name="param.destfile"/>
        <element name="param.listofitems"/>
        <sequential>
          <tar compression="gzip" longfile="gnu"
          destfile="@{param.destfile}">
          <param.listofitems/>
          </tar>
        </sequential>
      </macrodef>
    
  40.  <!-- the normal classpath -->
      <path id="classpath">
        <pathelement location="${build.classes}"/>
        <path refid="src.lib.classpath"/>
        <pathelement location="${conf.dir}"/>
      </path>
    
      <path id="src.lib.classpath">
        <fileset dir="${lib.dir}">
          <include name="**/*.jar" />
          <exclude name="**/excluded/" />
        </fileset>
        <path refid="ivy-common.classpath"/>
      </path>
    
      <path id="test.lib.classpath">
        <fileset dir="${test.lib.dir}">
          <include name="**/*.jar"/>
          <exclude name="**/excluded/"/>
        </fileset>
      </path>
    
  41. <!-- check if clover reports should be generated -->
      <condition property="clover.enabled">
        <and>
            <isset property="run.clover"/>
            <isset property="clover.present"/>
        </and>
      </condition>
    
      <condition property="staging">
         <equals arg1="${repo}" arg2="staging"/>
      </condition>
    
  42. <property environment="env" />
    
  43. <loadproperties srcfile="${ivy.dir}/libraries.properties"/>
    
  44. <exec executable="sed" inputstring="${os.name}" 
            outputproperty="nonspace.os">
         <arg value="s/ /_/g"/>
      </exec>
    
  45. <condition property="os-arch" value="x86_64">
        <and>
          <os arch="amd64" />
        </and>
      </condition>
      <condition property="os-arch" value="i386">
        <or>
          <os arch="i386" />
          <os arch="i486" />
          <os arch="i586" />
          <os arch="i686" />
          <os arch="x86" />
        </or>
      </condition>

posted on 2013-07-19 20:06  lyeoswu  阅读(436)  评论(0编辑  收藏  举报

导航