首页 > 代码库 > 使用Eclipse&Ant编译hadoop2.x的eclipse插件

使用Eclipse&Ant编译hadoop2.x的eclipse插件

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

1、下载插件源码包

https://github.com/winghc/hadoop2x-eclipse-plugin

2、新建eclisep java工程,将压缩包中以下目录的内容复制到project中

hadoop2x-eclipse-plugin-master.zip\hadoop2x-eclipse-plugin-master\src\contrib\eclipse-plugin

3、增加依赖库

其中hadoop-2.4.1的jar来自hadoop主目录下的

\hadoop-2.4.1\share\hadoop\

Plug-in依赖则直接添加自定义library即可

4、修改build.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this 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 with
   the License.  You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software
   distributed 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 and
   limitations under the License.
-->
<project name="eclipse-plugin" default="jar">
    <!-- 这里的路径都要改啊! -->
 <property name="jdk.home" value=http://www.mamicode.com/"D:/Program Files/Java/jdk1.7.0_60" />> 

5、在build.xml文件上Run AS Ant Build

Buildfile: D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build.xml

init:

     [echo] contrib: eclipse-plugin

    [mkdir] Created dir: D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin

    [mkdir] Created dir: D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\classes

    [mkdir] Created dir: D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\lib

     [copy] Copying 35 files to D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\lib

     [copy] Copying D:\Lab\lib\HADOOP\hadoop-2.4.1\share\hadoop\common\lib\commons-cli-1.2.jar to D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\lib\commons-cli-1.2.jar

     [copy] Copying D:\Lab\lib\HADOOP\hadoop-2.4.1\share\hadoop\common\lib\commons-collections-3.2.1.jar to D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\lib\commons-collections-3.2.1.jar

     [copy] Copying D:\Lab\lib\HADOOP\hadoop-2.4.1\share\hadoop\common\lib\commons-configuration-1.6.jar to D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\lib\commons-configuration-1.6.jar

     此处省略若干字。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

compile:

     [echo] contrib: eclipse-plugin

    [javac] Compiling 45 source files to D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\classes

    [javac] 注: 某些输入文件使用或覆盖了已过时的 API。

    [javac] 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。

    [javac] 注: 某些输入文件使用了未经检查或不安全的操作。

    [javac] 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
jar:

      [jar] Building jar: D:\Lab\ws-back-end\Hadoop2x-eclipse-plugin\build\contrib\eclipse-plugin\hadoop-2.4.1-eclipse-4.4-plugin.jar

init:

     [echo] contrib: eclipse-plugin

compile:

     [echo] contrib: eclipse-plugin

BUILD SUCCESSFUL

Total time: 11 seconds

6、到这里找编译好的jar

使用Eclipse&Ant编译hadoop2.x的eclipse插件