eclipse插件的編譯——Hadoop1.2.0版

因爲1.0以後hadoop已經不自帶eclipse的插件包了,因此得須要咱們本身編譯源碼生成插件包。

hadoop的目錄在/root/hadoop-1.2.0下面
eclipse的目錄在/root/eclipse下面
總結一下以下的四步來完成編譯eclipse插件的過程


步驟操做1進入/root/hadoop-1.2.0/src/contrib/eclipse-plugin下面,修改build.xml2進入/root/hadoop-1.2.0/src/contrib下面,修改build-contrib.xml3/root/hadoop-1.2.0/src/contrib/eclipse-plugin/META-INF下面,修改MANIFEST.MF文件4使用shell命令進入/root/hadoop-1.2.0/src/contrib/eclipse-plugin下面,執行ant命令進行構建

下面散仙就來詳細介紹下,每一步具體怎麼操做,在第一步裏咱們須要向build.xml裏面,加入的內容有
1,eclipse的根目錄.
2.hadoop的版本號.
3.hadoop的一些引用包.
4,在javac里加入  includeantruntime="on".
內容以下所示:


Xml代碼   收藏代碼
  1. <!-- 1,2步的配置  -->java

  2. <propertyname="eclipse.home"location="/root/eclipse"/>shell

  3. <propertyname="version"value="1.2.0"/>express

  4. <!--第3步的配置  -->apache

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

  6. <copyfile="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar"tofile="${build.dir}/lib/commons-cli.jar"verbose="true"/>less

  7. <copyfile="${hadoop.root}/lib/commons-configuration-1.6.jar"tofile="${build.dir}/lib/commons-configuration.jar"verbose="true"/>eclipse

  8. <copyfile="${hadoop.root}/lib/commons-httpclient-3.0.1.jar"tofile="${build.dir}/lib/commons-httpclient.jar"verbose="true"/>ssh

  9. <copyfile="${hadoop.root}/lib/commons-lang-2.4.jar"tofile="${build.dir}/lib/commons-lang.jar"verbose="true"/>ide

  10. <copyfile="${hadoop.root}/lib/jackson-core-asl-1.8.8.jar"tofile="${build.dir}/lib/jackson-core-asl.jar"verbose="true"/>oop

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

  12. <!--第4步的配置  -->

  13. includeantruntime="on">


散仙會在下文貼出整個XML,如今咱們看第二大步的配置,修改build-contrib.xml,內容以下:
Xml代碼   收藏代碼
  1. <!--  原始的爲off -->

  2. lt;property name="javac.deprecation"value="on"/>


第三步的修改MANIFEST.MF內容以下:
Xml代碼   收藏代碼
  1. Bundle-ClassPath: classes/,lib/commons-cli.jar,lib/commons-httpclient.jar,lib/hadoop-core.jar,lib/jackson-mapper-asl.jar,lib/commons-configuration.jar,lib/commons-lang.jar,lib/jackson-core-asl.jar  



第四步執行命令:截圖以下:

575a3a9a-82be-38bc-ad3c-e8c03f6b069b.jpg
最後,插件類生成的目錄,截圖以下:


77a37c76-dba2-329f-b5f0-fce95ace2d12.jpg

下面散仙給出全部配置的所有信息,以供參考,下圖的是build.xml裏面的內容


Xml代碼   收藏代碼
  1. <?xmlversion="1.0"encoding="UTF-8"standalone="no"?>


  2. <!--  

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

  4.   contributor license agreements.  See the NOTICE file distributed with  

  5.   this work for additional information regarding copyright ownership.  

  6.   The ASF licenses this file to You under the Apache License, Version 2.0  

  7.   (the "License"); you may not use this file except in compliance with  

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


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


  10.   Unless required by applicable law or agreed to in writing, software  

  11.   distributed under the License is distributed on an "AS IS" BASIS,  

  12.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  

  13.   See the License for the specific language governing permissions and  

  14.   limitations under the License.  

  15. -->


  16. <!-- build.xml -->

  17. <projectdefault="jar"name="eclipse-plugin">


  18. <importfile="../build-contrib.xml"/>



  19. <propertyname="eclipse.home"location="/root/eclipse"/>

  20. <propertyname="version"value="1.2.0"/>


  21. <pathid="eclipse-sdk-jars">

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

  23. <includename="org.eclipse.ui*.jar"/>

  24. <includename="org.eclipse.jdt*.jar"/>

  25. <includename="org.eclipse.core*.jar"/>

  26. <includename="org.eclipse.equinox*.jar"/>

  27. <includename="org.eclipse.debug*.jar"/>

  28. <includename="org.eclipse.osgi*.jar"/>

  29. <includename="org.eclipse.swt*.jar"/>

  30. <includename="org.eclipse.jface*.jar"/>


  31. <includename="org.eclipse.team.cvs.ssh2*.jar"/>

  32. <includename="com.jcraft.jsch*.jar"/>

  33. </fileset>

  34. </path>


  35. <!-- Override classpath to include Eclipse SDK jars -->

  36. <pathid="classpath">

  37. <pathelementlocation="${build.classes}"/>

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

  39. <filesetdir="${hadoop.root}">

  40. <includename="**/*.jar"/>

  41. </fileset>

  42. <pathrefid="eclipse-sdk-jars"/>

  43. </path>


  44. <!-- Skip building if eclipse.home is unset. -->

  45. <targetname="check-contrib"unless="eclipse.home">

  46. <propertyname="skip.contrib"value="yes"/>

  47. <echomessage="eclipse.home unset: skipping eclipse plugin"/>

  48. </target>


  49. <targetname="compile"depends="init, ivy-retrieve-common"unless="skip.contrib">

  50. <echomessage="contrib: ${name}"/>

  51. <javac

  52. encoding="${build.encoding}"

  53. srcdir="${src.dir}"

  54. includes="**/*.java"

  55. destdir="${build.classes}"

  56. debug="${javac.debug}"

  57. deprecation="${javac.deprecation}"

  58. includeantruntime="on">

  59. <classpathrefid="classpath"/>

  60. </javac>

  61. </target>


  62. <!-- Override jar target to specify manifest -->

  63. <targetname="jar"depends="compile"unless="skip.contrib">

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

  65. <!--  <copy file="${hadoop.root}/build/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> -->

  66. <!--  <copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar"  todir="${build.dir}/lib" verbose="true"/>-->

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

  68. <copyfile="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar"tofile="${build.dir}/lib/commons-cli.jar"verbose="true"/>

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

  70. <copyfile="${hadoop.root}/lib/commons-httpclient-3.0.1.jar"tofile="${build.dir}/lib/commons-httpclient.jar"verbose="true"/>

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

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

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



  74. <jar

  75. jarfile="${build.dir}/hadoop-${name}-${version}.jar"

  76. manifest="${root}/META-INF/MANIFEST.MF">

  77. <filesetdir="${build.dir}"includes="classes/ lib/"/>

  78. <filesetdir="${root}"includes="resources/ plugin.xml"/>

  79. </jar>

  80. </target>


  81. </project>


build-contrib.xml的核心配置以下:只有一個地方,notepad++,定位截圖以下:
Xml代碼   收藏代碼
  1. <propertyname="javac.deprecation"value="on"/>



3240219a-e2c5-355e-9228-693e6b968a24.jpg
下面是MANIFEST.MF裏面的內容

Java代碼   收藏代碼
  1. Manifest-Version: 1.0

  2. Bundle-ManifestVersion: 2

  3. Bundle-Name: MapReduce Tools for Eclipse  

  4. Bundle-SymbolicName: org.apache.hadoop.eclipse;singleton:=true

  5. Bundle-Version: 0.18

  6. Bundle-Activator: org.apache.hadoop.eclipse.Activator  

  7. Bundle-Localization: plugin  

  8. Require-Bundle: org.eclipse.ui,  

  9. org.eclipse.core.runtime,  

  10. org.eclipse.jdt.launching,  

  11. org.eclipse.debug.core,  

  12. org.eclipse.jdt,  

  13. org.eclipse.jdt.core,  

  14. org.eclipse.core.resources,  

  15. org.eclipse.ui.ide,  

  16. org.eclipse.jdt.ui,  

  17. org.eclipse.debug.ui,  

  18. org.eclipse.jdt.debug.ui,  

  19. org.eclipse.core.expressions,  

  20. org.eclipse.ui.cheatsheets,  

  21. org.eclipse.ui.console,  

  22. org.eclipse.ui.navigator,  

  23. org.eclipse.core.filesystem,  

  24. org.apache.commons.logging  

  25. Eclipse-LazyStart: true

  26. Bundle-ClassPath: classes/,lib/commons-cli.jar,lib/commons-httpclient.jar,lib/hadoop-core.jar,lib/jackson-mapper-asl.jar,lib/commons-configuration.jar,lib/commons-lang.jar,lib/jackson-core-asl.jar  

  27. Bundle-Vendor: Apache Hadoop  


至此,已經ant編譯完畢,截圖以下


4701c572-0285-37ac-83aa-4436a950854a.jpg
啓動eclipse後,截圖以下:

376c4dd8-8ec9-3744-add8-8f5e7d8f8382.jpg



至此,插件已經完美生成,並運行,由於受上傳限制的影響,因此散仙在這裏上傳不了這個jar包。
相關文章
相關標籤/搜索