转载: 博客园 刺猬的温驯
修改${hadoop.root}/src/contrib目录的build-contrib.xml文件,添加eclipse路径和hadoop版本信息
<property name="eclipse.home" location="D:/Program Files/eclipse" /> <property name="version" value="1.1.2"/>
修改${hadoop.root}/src/contrib/eclipse-plugin目录下的build.xml文件,在id为classpath的path节点添加hadoop-core的jar依赖
<!-- Override classpath to include Eclipse SDK jars --> <path id="classpath"> <pathelement location="${build.classes}"/> <pathelement location="${hadoop.root}/build/classes"/> <!--hadoop-core --> <pathelement location="${hadoop.root}/hadoop-core-1.1.2.jar"/> <path refid="eclipse-sdk-jars"/> </path>
找到name为jar的target,将相应的jar文件打包进插件的lib目录
<!-- 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-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> <copy file="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/> <!-- 将以下jar包打进hadoop-eclipse-1.1.2.jar中 --> <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>
修改MANIFEST.MF文件里面Bundle-ClassPath属性值
Bundle-ClassPath: classes/,lib/hadoop-core.jar,lib/commons-cli-1.2.jar,lib/commons-configuration-1.6.jar,lib/commons-httpclient-3.0.1.jar,lib/commons-lang-2.4.jar,lib/jackson-core-asl-1.8.8.jar,lib/jackson-mapper-asl-1.8.8.jar
在命令行进入 ${hadoop.root}/src/contrib/eclipse-plugin目录,输入ant命令
最后在${hadoop.root}/build/contrib/eclipse-plugin目录生成打包好的插件,将hadoop-eclipse-plugin-1.1.2.jar文件复制到eclipse的plugins目录即可