使用Eclipse&Ant編譯hadoop1.x的eclipse外掛程式

來源:互聯網
上載者:User

標籤:des   http   java   os   使用   io   檔案   for   ar   

注意:以下操作基於Hadoop-1.2.1,Eclipse Luna

1、將hadoop eclipse外掛程式的工程匯入Eclipse。外掛程式源碼目錄如下:

D:\Lab\lib\hadoop\hadoop-1.2.1\src\contrib\eclipse-plugin

2、配置工程依賴

3、準備ant的設定檔

D:\Lab\lib\hadoop\hadoop-1.2.1\src\contrib\build-contrib.xml

將以上build-contrib.xml拷貝到項目目錄中,並修改檔案內容。具體如下:

  <property name="name" value="${ant.project.name}"/>  <property name="root" value="${basedir}"/>  <property name="hadoop.root" location="D:/Lab/lib/hadoop/hadoop-1.2.1"/>  <property name="eclipse.home" location="D:/Program Files/Eclipse/eclipse-jee-luna-R-win32-x86_64"/>  <property name="version" value="1.2.1"/>  <property name="build.contrib.dir" location="${root}/build/contrib"/>  <property name="build.dir" location="${root}/build/contrib/${name}"/>

4、修改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><!-- 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" /><!--本行為新增內容--></path><!-- 3.修改並添加jar包,有些包已經有了,只添沒有的   --><!-- Override jar target to specify manifest --><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/commons-httpclient-3.0.1.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" />    <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>

5、修改MENIFEST.MF,在Bundule-ClassPath中增加一些依賴的jar。

Bundle-ClassPath: classes/, D:/Lab/lib/hadoop/hadoop-1.2.1/lib/hadoop-core-1.2.1.jar, D:/Lab/lib/hadoop/hadoop-1.2.1/lib/commons-cli-1.2.jar, D:/Lab/lib/hadoop/hadoop-1.2.1/lib/commons-configuration-1.6.jar, D:/Lab/lib/hadoop/hadoop-1.2.1/lib/commons-httpclient-3.0.1.jar, D:/Lab/lib/hadoop/hadoop-1.2.1/lib/commons-lang-2.4.jar, D:/Lab/lib/hadoop/hadoop-1.2.1/lib/jackson-core-asl-1.8.8.jar, D:/Lab/lib/hadoop/hadoop-1.2.1/lib/jackson-mapper-asl-1.8.8.jar

5、增加Ant Builder。

6、編譯

在Project菜單中Build Project

7、運行結果

Buildfile: D:\Lab\ws-back-end\MapReduceTools\build.xmlcheck-contrib:init:        [echo] contrib: eclipse-plugin       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\classes       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\test       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\system       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\system\classes       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\examples       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\test\logsinit-contrib:ivy-download:         [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.1.0/ivy-2.1.0.jar         [get] To: D:\Lab\lib\hadoop\hadoop-1.2.1\ivy\ivy-2.1.0.jar         [get] http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.1.0/ivy-2.1.0.jar moved to http://120.195.54.5:801/videoplayer/ivy-2.1.0.jar?ich_u_r_i=ae068fe40ff82e58486dd0954048cc19&ich_s_t_a_r_t=0&ich_e_n_d=0&ich_k_e_y=1445088923750763152452&ich_t_y_p_e=1&ich_d_i_s_k_i_d=6&ich_u_n_i_t=1         [get] Not modified - so not downloadedivy-probe-antlib:ivy-init-antlib:ivy-init:[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ ::[ivy:configure] :: loading settings :: file = D:\Lab\lib\hadoop\hadoop-1.2.1\ivy\ivysettings.xmlivy-resolve-common:ivy-retrieve-common:[ivy:cachepath] DEPRECATED: ‘ivy.conf.file‘ is deprecated, use ‘ivy.settings.file‘ instead[ivy:cachepath] :: loading settings :: file = D:\Lab\lib\hadoop\hadoop-1.2.1\ivy\ivysettings.xmlcompile:        [echo] contrib: eclipse-plugin       [javac] D:\Lab\ws-back-end\MapReduceTools\build.xml:65: warning: ‘includeantruntime‘ was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds       [javac] Compiling 45 source files to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\classes       [javac] 注: 某些輸入檔案使用或覆蓋了已淘汰的 API。       [javac] 注: 有關詳細資料, 請使用 -Xlint:deprecation 重新編譯。       [javac] 注: 某些輸入檔案使用了未經檢查或不安全的操作。       [javac] 注: 有關詳細資料, 請使用 -Xlint:unchecked 重新編譯。jar:       [mkdir] Created dir: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying 1 file to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying D:\Lab\lib\hadoop\hadoop-1.2.1\hadoop-core-1.2.1.jar to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib\hadoop-core.jar        [copy] Copying 1 file to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying D:\Lab\lib\hadoop\hadoop-1.2.1\lib\commons-cli-1.2.jar to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib\commons-cli-1.2.jar        [copy] Copying 1 file to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying D:\Lab\lib\hadoop\hadoop-1.2.1\lib\commons-lang-2.4.jar to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib\commons-lang-2.4.jar        [copy] Copying 1 file to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying D:\Lab\lib\hadoop\hadoop-1.2.1\lib\commons-configuration-1.6.jar to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib\commons-configuration-1.6.jar        [copy] Copying 1 file to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying D:\Lab\lib\hadoop\hadoop-1.2.1\lib\commons-httpclient-3.0.1.jar to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib\commons-httpclient-3.0.1.jar        [copy] Copying 1 file to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying D:\Lab\lib\hadoop\hadoop-1.2.1\lib\jackson-mapper-asl-1.8.8.jar to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib\jackson-mapper-asl-1.8.8.jar        [copy] Copying 1 file to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib        [copy] Copying D:\Lab\lib\hadoop\hadoop-1.2.1\lib\jackson-core-asl-1.8.8.jar to D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\lib\jackson-core-asl-1.8.8.jar         [jar] Building jar: D:\Lab\ws-back-end\MapReduceTools\build\contrib\eclipse-plugin\hadoop-eclipse-plugin-1.2.1.jarBUILD SUCCESSFULTotal time: 6 seconds


使用Eclipse&Ant編譯hadoop1.x的eclipse外掛程式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.