编译hadoop的eclipse插件hadoop-eclipse-plugin-1.2.1.jar
1:下載后hadoop-1.1.2.tar.gz文件,里面包含源代碼,并解壓到E:\hadoop\hadoop-1.2.1
2:在eclipse導入工程,目錄選擇:E:\hadoop\hadoop-1.2.1\src\contrib\eclipse-plugin
3:在項目 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 拷貝到該目錄。
4:修改項目的Libraries
5:修改build-contrib.xml
將E:\hadoop\hadoop-1.2.1\src\contrib目錄下的build-contrib.xml文件拷貝到項目目錄中,注意:build-contrib.xml文件以eclipse-plugin是在同一級目錄中,拷貝完成以后修改build-contrib.xml文件。修改的內(nèi)容如下。
<property name="name" value="${ant.project.name}"/><property name="root" value="${basedir}"/><property name="version" value="1.2.1"/> <!--這行為新增的內(nèi)容--><property name="hadoop.root" location="E:/hadoop/hadoop-1.2.1"/><!--這行為修改的內(nèi)容--><property name="eclipse.home" location="E:/work/eclipse-jee-kepler-SR2-win32/eclipse" /><!--這行為修改的內(nèi)容-->
6:修改build.xml
如果導入項目的時候選擇的是copy的話,需要E:\hadoop\hadoop-1.2.1\src\contrib\eclipse-plugin下的build.xml文件拷貝到項目目錄中,不是的話直接修改。
下面是完整的內(nèi)容:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. --><project default="jar" name="eclipse-plugin"><!-- 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="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> </path><!-- Override classpath to include Eclipse SDK jars --><path id="classpath"><pathelement location="${build.classes}"/><pathelement location="${hadoop.root}/build/classes"/><path refid="eclipse-sdk-jars"/><path refid="hadoop-jars"/> <!--這行為添加的內(nèi)容--></path><!-- Skip building if eclipse.home is unset. --><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}"/><javacencoding="${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 specify manifest --><target name="jar" depends="compile" unless="skip.contrib"><mkdir dir="${build.dir}/lib"/><!--這行為添加的內(nèi)容--><copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core-${version}.jar" verbose="true"/><!--這行為添加的內(nèi)容--><!--<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}/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"/><jarjarfile="${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>7:修改MANIFEST.MF
在Bundle-ClassPath添加下面的內(nèi)容 Bundle-ClassPath: classes/,lib/hadoop-core.jar,lib/
8:Ant 編譯
a. 右鍵 MapReduceTools 工程,Properties—>Builders—>New—>Ant Builder
b. 修改New_Builder編輯界面中的內(nèi)容
Name (見名知意): hadoop_Builder
Buildfile (build.xml的位置): 項目路徑下面\build.xml
3. 修改完成保存
4. 點擊Project—>Build Project進行生成
點擊Project—>Build Project開始進行生成,這時候我們會看到控制臺輸出一堆相關的編譯信息,編譯成功會看到在控制臺輸出 BUILD SUCCESSFUL 。編譯結果在 E:\hadoop\hadoop-1.2.1\build\contrib\eclipse-plugin目錄下。
安裝插件
安裝插件到eclipse的話就需要將 hadoop-eclipse-plugin-1.2.1.jar 放入 到eclipse的plugins 目錄下,重啟 eclipse即可。
總結
以上是生活随笔為你收集整理的编译hadoop的eclipse插件hadoop-eclipse-plugin-1.2.1.jar的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: awk进行文本处理
- 下一篇: Win系统下用Eclipse中运行远程h