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代码  eclipse插件的编译——Hadoop1.2.0版
  1. <!-- 1,2步的配置  -->

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

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

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

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

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

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

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

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

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

  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代码  eclipse插件的编译——Hadoop1.2.0版
  1. <!--  原始的为off -->

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


第三步的修改MANIFEST.MF内容如下:
Xml代码  eclipse插件的编译——Hadoop1.2.0版
  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  



第四步执行命令:截图如下:

eclipse插件的编译——Hadoop1.2.0版
最后,插件类生成的目录,截图如下:


eclipse插件的编译——Hadoop1.2.0版

下面散仙给出所有配置的全部信息,以供参考,下图的是build.xml里面的内容


Xml代码  eclipse插件的编译——Hadoop1.2.0版
  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代码  eclipse插件的编译——Hadoop1.2.0版
  1. <propertyname="javac.deprecation"value="on"/>



eclipse插件的编译——Hadoop1.2.0版
下面是MANIFEST.MF里面的内容

Java代码  eclipse插件的编译——Hadoop1.2.0版
  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编译完毕,截图如下


eclipse插件的编译——Hadoop1.2.0版
启动eclipse后,截图如下:

eclipse插件的编译——Hadoop1.2.0版



至此,插件已经完美生成,并运行,因为受上传限制的影响,所以散仙在这里上传不了这个jar包。


本文出自 “DavideyLee” 博客,请务必保留此出处http://davideylee.blog.51cto.com/8703117/1381074

eclipse插件的编译——Hadoop1.2.0版,布布扣,bubuko.com

eclipse插件的编译——Hadoop1.2.0版

上一篇:关于小程序globalData


下一篇:实战丨如何制作一个完整的外卖小程序(已开源)