hadoop1.2.1 eclipse 插件生成
目录结构
eclipse目录 F:\eclipse
eclipse工程目录 F:\workspace
Step1: 导入 Hadoop-eclipse 插件工程
获取 hadoop-1.2.1.tar.gz
解压缩到 Eclipse workspace 目录下
在 Eclipse 中选择 File—>Import—>Existing Projects into Workspace 导入已有项目,路径为: F:\workspace\hadoop-1.2.1\src\contrib\eclipse-plugin,其默认的项目名称是 MapReduceTools
Step2: 导入所需 jar 包
在项目 MapReduceTools 中新建 lib 目录,将 hadoop-1.2.1 下的 hadoop-core-1.2.1.jar,及其 lib 目录下的 commons-cli-1.2.jar、commons-lang-2.4.jar、commons-configuration-1.6.jar、 jackson-mapper-asl-1.8.8.jar、jackson-core-asl-1.8.8.jar、commons- httpclient-3.0.1.jar 拷贝到该目录。
Step3: build-contrib.xml
将 F:\workspace\hadoop-1.2.1\src\contrib\build-contrib.xml(与 eclipse-plugin 包在同一级目录)拷贝到 MapReduceTools 项目目录中。
修改 build-contrib.xml,注意路径用 "/"
<!— 修改 hadoop 存放目录—>
<property name="hadoop.root" location="F:/workspace/hadoop-1.2.1"/>
<!— 添加 eclipse 存放目录—>
<property name="eclipse.home" location="F:/eclipse" />
<!— 添加 hadoop 版本—>
<property name="version" value="1.2.1"/>
Step4: build.xml
<!— 1.修改 build-contrib.xml 的位置,去掉"../"—>
<import file="build-contrib.xml"/>
<!— 2.添加如下,否则提示"软件包 org.apache.hadoop.fs 不存在"—>
<path id="hadoop-jars">
<fileset dir="${hadoop.root}/">
<include name="hadoop-*.jar"/>
</fileset>
</path>
<path id="classpath">
<pathelement location="${build.classes}"/>
<pathelement location="${hadoop.root}/build/classes"/>
<path refid="eclipse-sdk-jars"/>
<path refid="hadoop-jars"/>
</path>
<!— 3.修改并添加 jar 包拷贝—>
<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>
Step5: MANIFEST.MF
修改 META-INF/MANIFEST.MF
Bundle-ClassPath: classes/,
lib/hadoop-core.jar ,
lib/commons-cli-1.2.jar,
lib/commons-httpclient-3.0.1.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
Step6: Ant 编译
右键 MapReduceTools 工程,Properties—>Builders—>New—>Ant Builder
New_Builder—>Edit:
Name (见名知意): plugin_Builder
Buildfile (build.xml的位置): F:\workspace\hadoop-1.2.1\src\contrib\eclipse-plugin\build.xml
Project—>Build Project
编译成功会输出 BUILD SUCCESSFUL ^^
Step7: 安装插件
编译结果在 F:\workspace\hadoop-1.2.1\build\contrib\eclipse-plugin 目录下
将 hadoop-eclipse-plugin-1.2.1.jar 放入 F:\eclipse\plugins 目录下,重启 eclipse