一、安装ant
#sudo apt-get install ant
二、修改编译配置文件
1、在hadoop安装目录下找到src/contrib/eclipse-plugin/build.xml,修改以下几行:
<path id="hadoop-core-jar"> <fileset dir="${hadoop.root}/"> <include name="hadoop*.jar"/> </fileset> </path> <!-- Override classpath to include Eclipse SDK jars --> <path id="classpath"> <pathelement location="${build.classes}"/> <pathelement location="${hadoop.root}/build/classes"/> <path refid="eclipse-sdk-jars"/> <path refid="hadoop-core-jar"/> </path>
......
<target name="jar" depends="compile" unless="skip.contrib"> <mkdir dir="${build.dir}/lib"/> <copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> <copy file="${hadoop.root}/lib/commons-cli-1.2.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-lang-2.4.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-configuration-1.6.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/jackson-mapper-asl-1.8.8.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/jackson-core-asl-1.8.8.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-httpclient-3.0.1.jar" todir="${build.dir}/lib" 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、在/src/contrib/下找到build-contrib.xml,添加如下内容:
<property name="version" value="1.2.1"/> <property name="ivy.version" value="2.1.0"/> <property name="eclipse.home" location="..."/>
注:eclipse的路径请换成你主机上的eclipse存放路径。
3、在src/contrib/eclipse-plugin目录下找到META-INF/MANIFEST.MF文件更改如下内容:
将Bundle-ClassPath: classes/,lib/hadoop-core.jar改为
Bundle-ClassPath: classes/,lib/hadoop-core.jar,lib/jackson-core-asl-1.8.8.jar ,lib/jackson-mapper-asl-1.8.8.jar, lib/commons-configuration-1.6.jar,lib/commons-lang-2.4.jar, lib/commons-httpclient-3.0.1.jar,lib/commons-cli-1.2.jar
4、返回src/contrib/eclipse-plugin编译
ant
5、在{hadoophome}/build/contrib/eclipse-plugin下找到编译好的插件hadoop-eclipse-plugin-1.2.1.jar并将其copy到eclipse下的plugin目录下({hadoophome}为hadoop安装目录)
注意:1、在有网络连接的环境下安装
2、编译的插件与eclipse版本没有关系,仅与hadoop版本和eclipse的安装目录有关系
转载于:https://blog.51cto.com/6728496/1303425