1. 下载hadoop-2.0.0-cdh4.2.2.tar.gz
2.解压tar -zxvf hadoop-2.0.0-cdh4.2.2.tar.gz
3.进入目录./hadoop-2.0.0-mr1-cdh4.2.2/src/contrib,修改build-contrib.xml文件
<!-- 原内容为off -->
<property name="javac.deprecation" value="on"/>
4.进入目录./hadoop-2.0.0-mr1-cdh4.2.2/src/contrib/eclipse-plugin
(1)修改build.xml(红色部分为修改或添加的内容)
<project default="jar" name="eclipse-plugin">
<import file="../build-contrib.xml"/>
<property name="eclipse.home" location="eclipse安装目录" />
<property name="version" value="2.0.0-cdh4.2.2" />
。。。。
<path id="classpath">
<pathelement location="${build.classes}"/>
<pathelement location="${hadoop.root}/build/classes"/>
<fileset dir="${hadoop.root}">
<include name="**/*.jar" />
</fileset>
<path refid="eclipse-sdk-jars"/>
</path>
。。。
<target name="compile" depends="init, ivy-retrieve-common" unless="skip.contrib">
<echo message="contrib: ${name}"/>
<javac
encoding="${build.encoding}"
srcdir="${src.dir}"
includes="**/*.java"
destdir="${build.classes}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
includeantruntime="on">
<classpath refid="classpath"/>
</javac>
</target>
<!-- Override jar target to specify manifest -->
<target name="jar" depends="compile" unless="skip.contrib">
<mkdir dir="${build.dir}/lib"/>
<!-- <copy file="${hadoop.root}/build/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> -->
<!-- <copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/> -->
<copy file="${hadoop.root}/hadoop-core-2.0.0-mr1-cdh4.2.2.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar" tofile="${build.dir}/lib/commons-cli.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-configuration-1.6.jar" tofile="${build.dir}/lib/commons-configuration.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-httpclient-3.1.jar" tofile="${build.dir}/lib/commons-httpclient.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-lang-2.5.jar" tofile="${build.dir}/lib/commons-lang.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-core-asl-1.8.8.jar" tofile="${build.dir}/lib/jackson-core-asl.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-mapper-asl-1.8.8.jar" tofile="${build.dir}/lib/jackson-mapper-asl.jar" verbose="true"/>
<jar
jarfile="${build.dir}/hadoop-${name}-${version}.jar"
manifest="${root}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}" includes="classes/ lib/"/>
<fileset dir="${root}" includes="resources/ plugin.xml"/>
</jar>
</target>
(2)修改build.properties(添加如下内容)
reactor.repo=https://repository.cloudera.com/content/repositories/snapshots
5.在当前目录下运行ant命令
6.将生成的hadoop-eclipse-plugin-2.0.0-cdh4.2.2.jar拷贝到Eclipse安装目录的plugins目录下,运行Eclipse