君子博学而日参省乎己 则知明而行无过矣

博客园 首页 新随笔 联系 订阅 管理

网上讲的用Ant编译eclipse hadoop plugin插件,都讲的很复杂,对于我这样的菜鸟哪里经得起这么多折腾,本人经过实践,写出我的编译经验

首先请预先安装ant并设置环境变量,下载hadoop-1.1.2.tar.gz源码解压

修改${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目录即可

插件下载地址 http://download.csdn.net/detail/chenying998179/5349451

---------------------------------------------------------------------------

本系列Hadoop1.1.2开发笔记系本人原创

转载请注明出处 博客园 刺猬的温驯

本文链接 http://www.cnblogs.com/chenying99/archive/2013/05/09/3069228.html

posted on 2013-05-09 16:31  刺猬的温驯  阅读(2795)  评论(1编辑  收藏  举报