2.进入目录 ant 即可实现编译(保证ant安装正确,build.xml有此文件)
1.根据build.xml 会自动生成相应的class与jar
3.手工生成相应的包
hadoop-0.20.2-ant.jar
hadoop-0.20.2-core.jar
hadoop-0.20.2-examples.jar
hadoop-0.20.2-test.jar
hadoop-0.20.2-tools.jar
比如手工生成 hadoop-0.20.2-core.jar
需重写build.xml 如下
<?xml version="1.0"?>
<project name="Hadoop" default="jar"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="${user.home}/build.properties" />
<property file="${basedir}/build.properties" />
<property name="Name" value="Hadoop"/>
<property name="name" value="hadoop"/>
<property name="version" value="0.20.3-dev"/>
<property name="final.name" value="${name}-${version}"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="conf.dir" value="${basedir}/conf"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.webapps" value="${build.dir}/webapps"/>
<target name="jar" description="Make hadoop.jar">
<tar compression="gzip" destfile="${build.classes}/bin.tgz">
<tarfileset dir="bin" mode="755"/>
</tar>
<jar jarfile="${build.dir}/${final.name}-core.jar"
basedir="${build.classes}">
<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>
<fileset file="${conf.dir}/commons-logging.properties"/>
<fileset file="${conf.dir}/log4j.properties"/>
<fileset file="${conf.dir}/hadoop-metrics.properties"/>
<zipfileset dir="${build.webapps}" prefix="webapps"/>
</jar>
</target>
</project>
<project name="Hadoop" default="jar"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="${user.home}/build.properties" />
<property file="${basedir}/build.properties" />
<property name="Name" value="Hadoop"/>
<property name="name" value="hadoop"/>
<property name="version" value="0.20.3-dev"/>
<property name="final.name" value="${name}-${version}"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="conf.dir" value="${basedir}/conf"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.webapps" value="${build.dir}/webapps"/>
<target name="jar" description="Make hadoop.jar">
<tar compression="gzip" destfile="${build.classes}/bin.tgz">
<tarfileset dir="bin" mode="755"/>
</tar>
<jar jarfile="${build.dir}/${final.name}-core.jar"
basedir="${build.classes}">
<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>
<fileset file="${conf.dir}/commons-logging.properties"/>
<fileset file="${conf.dir}/log4j.properties"/>
<fileset file="${conf.dir}/hadoop-metrics.properties"/>
<zipfileset dir="${build.webapps}" prefix="webapps"/>
</jar>
</target>
</project>
4.将编译之后的
hadoop-0.20.2-ant.jar
hadoop-0.20.2-core.jar(经过测试,可以启动hadoop,说明没问题)
hadoop-0.20.2-examples.jar
hadoop-0.20.2-test.jar
hadoop-0.20.2-tools.jar
替换至hadoop目录
5.下一步,将试着修改源代码