hadoop1.2 eclipse插件编译

目录说明

 

     在编译之前,我们需要先下载后hadoop 1.2.1的源码文件,并解压到合适的位置。目录结构如下:

Eclipse: D:/eclipse

Hadoop: D:/hadoop-1.2.1


Step1导入 Hadoop-eclipse 插件工程

1.
下载hadoop-1.2.1.tar.gz,并解压缩到 D盘根目录下
2. 在 Eclipse 中选择 File—>Import—>General/Existing Projectsinto Workspace 导入Hadoop的Eclipse插件项目。选择路径为D:/hadoop-1.2.1/src/contrib/eclipse-plugin,然后点击Finish.其默认的项目名称是 MapReduceTools。(最好将该文件提取出来导入)

Step2导入所需 jar 包

在项目 MapReduceTools 中新建 lib 目录,将 hadoop-1.2.1 下的 hadoop-core-1.2.1.jar(重命名为 hadoop-core.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


将D:/hadoop-1.2.1/src/contrib目录下的build-contrib.xml文件拷贝到项目目录中,注意:build-contrib.xml文件拷贝到当前项目的一级目录中,拷贝完成以后修改build-contrib.xml文件。修改的内容如下。

<!– 修改 hadoop 存放目录   –>

<property name=”hadoop.root”location=”D:/hadoop-1.2.1″/>

<!– 添加 eclipse 存放目录  –>

<property name=”eclipse.home”location=”D:/eclipse” />

<!– 添加 hadoop 版本   –>

<property name=”version”value=”1.2.1″/>

Step4修改build.xml

<?xmlversion=”1.0″ encoding=”UTF-8″standalone=”no”?>

 

<!–

   Licensed to the Apache Software Foundation(ASF) under one or more

   contributor license agreements.  See the NOTICE file distributed with

   this work for additional informationregarding copyright ownership.

   The ASF licenses this file to You under theApache License, Version 2.0

   (the “License”); you may not usethis file except in compliance with

   the License. You may obtain a copy of the License at

 

      http://www.apache.org/licenses/LICENSE-2.0

 

   Unless required by applicable law or agreedto in writing, software

   distributed under the License is distributedon an “AS IS” BASIS,

   WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied.

   See the License for the specific languagegoverning permissions and

   limitations under the License.

–>

 

<projectdefault=”jar” name=”eclipse-plugin”>

       <!– 1.修改 build-contrib.xml的位置,去掉”../” –>

  <importfile=”build-contrib.xml”/>

      

       <!– 2.添加如下,否则提示”软件包 org.apache.hadoop.fs 不存在” –>

       <path id=”hadoop-jars”>

              <fileset dir=”${hadoop.root}/”>

              <includename=”hadoop-*.jar”/>

              </fileset>

       </path>        

 

  <path id=”eclipse-sdk-jars”>

    <filesetdir=”${eclipse.home}/plugins/”>

      <includename=”org.eclipse.ui*.jar”/>

      <includename=”org.eclipse.jdt*.jar”/>

      <includename=”org.eclipse.core*.jar”/>

      <includename=”org.eclipse.equinox*.jar”/>

      <includename=”org.eclipse.debug*.jar”/>

      <includename=”org.eclipse.osgi*.jar”/>

      <includename=”org.eclipse.swt*.jar”/>

      <include name=”org.eclipse.jface*.jar”/>

 

      <includename=”org.eclipse.team.cvs.ssh3*.jar”/>

      <includename=”com.jcraft.jsch*.jar”/>

    </fileset>

  </path>

 

  <!– Override classpath to include EclipseSDK jars –>

  <path id=”classpath”>

    <pathelement location=”${build.classes}”/>

    <pathelementlocation=”${hadoop.root}/build/classes”/>

    <pathrefid=”eclipse-sdk-jars”/>

      <pathrefid=”hadoop-jars”/> <!–这行为添加的内容–>

  </path>

 

  <!– Skip building if eclipse.home isunset. –>

  <target name=”check-contrib” unless=”eclipse.home”>

    <property name=”skip.contrib”value=”yes”/>

    <echo message=”eclipse.home unset:skipping eclipse plugin”/>

  </target>

 

 <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}”>

     <classpath refid=”classpath”/>

    </javac>

  </target>

 

  <!– Override jar target to specifymanifest –>

  <target name=”jar”depends=”compile” unless=”skip.contrib”>

    <mkdirdir=”${build.dir}/lib”/>

      <!–这行为添加的内容–>

    <copyfile=”${hadoop.root}/hadoop-core-${version}.jar”tofile=”${build.dir}/lib/hadoop-core-${version}.jar”verbose=”true”/>

      <!–这行为添加的内容–>

      <!–

      <copyfile=”${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar”  todir=”${build.dir}/lib”verbose=”true”/>

     –>

       <copyfile=”${hadoop.root}/lib/commons-cli-1.2.jar”todir=”${build.dir}/lib” verbose=”true”/>

       <copyfile=”${hadoop.root}/lib/commons-lang-2.4.jar”todir=”${build.dir}/lib” verbose=”true”/>

       <copyfile=”${hadoop.root}/lib/commons-configuration-1.6.jar”todir=”${build.dir}/lib” verbose=”true”/>

       <copyfile=”${hadoop.root}/lib/jackson-mapper-asl-1.8.8.jar”todir=”${build.dir}/lib” verbose=”true”/>

       <copyfile=”${hadoop.root}/lib/jackson-core-asl-1.8.8.jar”todir=”${build.dir}/lib” verbose=”true”/>

       <copyfile=”${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>

 

</project>

Step5修改MANIFEST.MF

在Bundle-ClassPath添加下面的内容。

 

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

 

Step6Ant 编译1.右键 MapReduceTools 工程,Properties—>Builders—>New—>Ant Builder
2.
修改New_Builder编辑界面中的内容
Name (
见名知意): plugin_Builder
Buildfile (build.xml
的位置):D:/hadoop-1.2.1/src/contrib/eclipse-plugin/build.xml
3.
修改完成保存
4.
点击Project—>Build Project进行生成
点击Project—>Build Project开始进行生成,这时候我们会看到控制台输出一堆相关的编译信息,编译成功会看到在控制台输出 BUILD SUCCESSFUL 。编译结果在d:/hadoop-1.2.1/build/contrib/eclipse-plugin 目录下。
 

Step6查看编译成果

编译结果在 d:/hadoop-1.2.1/build/contrib/eclipse-plugin 目录下。我们可以看到在目录下生成了hadoop-eclipse-plugin-1.2.1.jar,这时如果我们需要安装插件到eclipse的话就需要将hadoop-eclipse-plugin-1.2.1.jar 放入 到eclipse的plugins 目录下,重启 eclipse即可。


原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/192934.html

(0)
上一篇 2021年11月15日
下一篇 2021年11月15日

相关推荐

发表回复

登录后才能评论