output.. = bin/
bin.includes = META-INF/,\
plugin.xml,\
resources/,\
classes/,\
classes/,\
lib/
#需定义的参数
eclipse.home=E:/GreenSoft/DevelopmentSoft/eclipse
version=1.2.1
jackson-core-asl.version=1.8.8
jackson-mapper-asl.version=1.8.8
4、修改build.xml配置文件
因为没有编译过整个Hadoop项目,所以Hadoop安装目录下的build目录中没有所需的jar文件。因此要手工修改编译所涉及的jar文件为Hadoop安装目录及其lib子目录下中的一共7个jar文件
(1)、设置elipse-sdk-jar path中也包含hadoop安装目录的jar文件。
<path id="eclipse-sdk-jars">
<fileset dir="${eclipse.home}/plugins/">
<include name="org.eclipse.ui*.jar"/>
<include name="org.eclipse.jdt*.jar"/>
<include name="org.eclipse.core*.jar"/>
<include name="org.eclipse.equinox*.jar"/>
<include name="org.eclipse.debug*.jar"/>
<include name="org.eclipse.osgi*.jar"/>
<include name="org.eclipse.swt*.jar"/>
<include name="org.eclipse.jface*.jar"/>
<include name="org.eclipse.team.cvs.ssh2*.jar"/>
<include name="com.jcraft.jsch*.jar"/>
</fileset>
<!-- 指定使用$HADOOP_HOME总的jar文件 -->
<fileset dir="${hadoop.root}">
<include name="hadoop-*.jar"/>
</fileset>
</path>
(2)、修改copy的jar文件路径
<!-- Override jar target to specify manifest -->
<target name="jar" depends="compile" unless="skip.contrib">
<mkdir dir="${build.dir}/lib"/>
<!-- 设置正确的所有jar文件复制 -->
<!--
<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"/>
<copy file="${hadoop.root}/lib/commons-configuration-${commons-configuration.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-httpclient-${commons-httpclient.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-lang-${commons-lang.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-core-asl-${jackson-core-asl.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-mapper-asl-${jackson-mapper-asl.version}.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>
4、修改MANIFEST.MF配置文件。
修改CLASSPATH,注意CLASSPATH中的每项都要以空格+逗号分隔,没有空格会报错。
注意jar文件的版本号,这里以hadoop-1.2.1为例。
Eclipse-LazyStart: true
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
Bundle-Vendor: Apache Hadoop
三、使用ANT编译插件
在Powershell中运行一下命令:
D:\apache-ant-1.9.2\bin\ant.bat四、复制插件到Eclipse插件目录
编译生成的插件在D:\hadoop-1.2.1\build\contrib\eclipse-plugin(Hadoop安装目录的build\contrib\eclipse-plugin目录中)。
只需要将hadoop-eclipse-plugin-*.jar文件拷贝到Eclipse安装目录的plugins文件夹中即可。
重启Eclipse就有Map/Reduce Perspective了。
参考资料:
Hadoop 1.2.1 eclipse plugin 编译 win7 集成 http://blog.****.net/reaper1022/article/details/11009797
hadoop-eclipse开发环境搭建及error: failure to login错误 http://blog.****.net/chengfei112233/article/details/7252404
MANIFEST.MF文件的Class-Path http://lost-alien.iteye.com/blog/646371