您的位置:首页 > 其它

ant学习笔记2

2013-07-19 20:06 246 查看
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。以下是我将要要学习的,如果有读者恰巧看到,以下就越过吧。太复杂了,我还没疏通。

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


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


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


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


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


<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>


<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>


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


<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>


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


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


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


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


<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>


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


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


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


<javadoc></javadoc>


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


<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>


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


<!--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'/>


<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>


<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>


<section></section>


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


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


<sequential> </sequential>


<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>


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


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


<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>


<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>


<target name="compile-native">
<antcall target="compile-core-native">
<param name="compile.native" value="true"/>
</antcall>
</target>


<jsp-compile
uriroot="${src.webapps}/task"
outputdir="${build.src}"
package="org.apache.hadoop.mapred"
webxml="${build.webapps}/task/WEB-INF/web.xml">
</jsp-compile>


<taskdef name="recordcc" classname="org.apache.hadoop.record.compiler.ant.RccTask">
<classpath refid="classpath" />
</taskdef>


<exec executable="sh">
<arg line="src/saveVersion.sh ${version} ${build.dir}"/>
</exec>


<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>


<!-- ====================================================== -->
<!-- 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>


<!-- 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>


<!-- 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>


<property environment="env" />


<loadproperties srcfile="${ivy.dir}/libraries.properties"/>


<exec executable="sed" inputstring="${os.name}"
outputproperty="nonspace.os">
<arg value="s/ /_/g"/>
</exec>


<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: