Hadoop安装以及配置(4)

编译eclipse plugin
==========================================================================
1、编辑${Hadoop_HOME}/src/contrib/下的build-contrib.xml文件
添加{version}和{eclipse.home}属性:
< !-- 这里定义了 version & eclipse.home -->
<property value="1.0.4"/>
< property value="/home/chqz/systool/eclipse/eclipse"/>
< property value="${ant.project.name}"/>
< property value="${basedir}"/>
< property location="${root}/../../../"/>


2、编辑${HADOOP_HOME}/src/contrib/eclipse-plugin/下的build.xml文件
(1) 添加hadoop-jars path,并同时加入到classpath中:
< !-- 这里添加了 hadoop-jars -->
<path>
< fileset dir="${hadoop.root}/">
< include/>
< /fileset>
< /path>

< !-- Override classpath to include Eclipse SDK jars -->
<path>
< pathelement location="${build.classes}"/>
< pathelement location="${hadoop.root}/build/classes"/>
< path refid="eclipse-sdk-jars"/>

< !-- 将 hadoop-jars 添加到这里 -->
<path refid="hadoop-jars"/>
< /path>

(2) 设置includeantruntime=on,防止compile时报warning:
<target 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}"
< !-- 设置includeantruntime=on,防止compile报warning -->
includeantruntime="on">
< classpath refid="classpath"/>
< /javac>
< /target>

(3) 添加将要打包到plugin中的第三方包列表:
< !-- Override jar target to specify manifest -->
<target depends="compile" unless="skip.contrib">
< mkdir dir="${build.dir}/lib"/>
<!-- 这里主要修改的是file中的值,注意路径一定要正确 -->
<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>


3、执行ant命令以生成hadoop-eclipse-plugin-${version}.jar包:
进入到${HADOOP_HOME}/src/contrib/eclipse-plugin/目录下,然后执行ant命令
最后成功生成的hadoop-eclipse-plugin-${version}.jar在${HADOOP_HOME}/build/contrib/eclipse-plugin下
如:/opt/apps/hadoop/build/contrib/eclipse-plugin/hadoop-eclipse-plugin-1.0.4.jar

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9a9f781006d112624193565acef32aae.html