ant 编译 hadoop-eclipse-plugin.jar包

1.安装 ant

sudo apt-get install ant

测试:
在这里插入图片描述

2.下载 hadoop

  1. 已配置 hadoop-2.7.3
    https://download.csdn.net/download/qq_38038143/10752615
  2. 未配置,源码包
    https://download.csdn.net/download/qq_38038143/10752696

3.编译

目录:

cd /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin

执行:

sudo ant jar -Dhadoop.version=2.7.3 -Declipse.home=/home/hadoop/eclipse -Dhadoop.home=/usr/local/hadoop

注:
-Dhadoop.version=2.7.3 ==> hadoop的版本
-Declipse.home ==> eclipse安装路径
-Dhadoop.home ==> hadoop安装路径

报如下错误(未报错可忽略):

hadoop@slave2:~/hadoop2x-eclipse-plugin/src/contrib/eclipse-plugin$ sudo ant jar -Dhadoop.version=2.7.3 -Declipse.home=/home/hadoop/eclipse -Dhadoop.home=/usr/local/hadoop
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-8-openjdk-amd64/lib/tools.jar
Buildfile: /home/hadoop/hadoop2x-eclipse-plugin/src/contrib/eclipse-plugin/build.xml

check-contrib:

init:
     [echo] contrib: eclipse-plugin

init-contrib:

ivy-probe-antlib:

ivy-init-antlib:

ivy-init:
[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ ::
[ivy:configure] :: loading settings :: file = /home/hadoop/hadoop2x-eclipse-plugin/ivy/ivysettings.xml

ivy-resolve-common:

ivy-retrieve-common:
[ivy:cachepath] DEPRECATED: 'ivy.conf.file' is deprecated, use 'ivy.settings.file' instead
[ivy:cachepath] :: loading settings :: file = /home/hadoop/hadoop2x-eclipse-plugin/ivy/ivysettings.xml

compile:
     [echo] contrib: eclipse-plugin
    [javac] /home/hadoop/hadoop2x-eclipse-plugin/src/contrib/eclipse-plugin/build.xml:76: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

BUILD FAILED
/home/hadoop/hadoop2x-eclipse-plugin/src/contrib/eclipse-plugin/build.xml:76: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-8-openjdk-amd64/jre"

Total time: 3 seconds

重点:

com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-8-openjdk-amd64/jre"

解决方法:
注:/usr/local/java/jdk1.8.0_152/为所在的 linux 的 jdk 路径

cp /usr/local/java/jdk1.8.0_152/lib/tools.jar  /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/

再次执行编译,如下成功:

hadoop@slave2:~/hadoop2x-eclipse-plugin/src/contrib/eclipse-plugin$ sudo ant jar -Dhadoop.version=2.7.3 -Declipse.home=/home/hadoop/eclipse -Dhadoop.home=/usr/local/hadoop
Buildfile: /home/hadoop/hadoop2x-eclipse-plugin/src/contrib/eclipse-plugin/build.xml

check-contrib:

init:
     [echo] contrib: eclipse-plugin

init-contrib:

ivy-probe-antlib:

ivy-init-antlib:

ivy-init:
[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ ::
[ivy:configure] :: loading settings :: file = /home/hadoop/hadoop2x-eclipse-plugin/ivy/ivysettings.xml

ivy-resolve-common:

ivy-retrieve-common:
[ivy:cachepath] DEPRECATED: 'ivy.conf.file' is deprecated, use 'ivy.settings.file' instead
[ivy:cachepath] :: loading settings :: file = /home/hadoop/hadoop2x-eclipse-plugin/ivy/ivysettings.xml

compile:
     [echo] contrib: eclipse-plugin
    [javac] /home/hadoop/hadoop2x-eclipse-plugin/src/contrib/eclipse-plugin/build.xml:76: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 45 source files to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/classes
    [javac] 注: 某些输入文件使用或覆盖了已过时的 API。
    [javac] 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
    [javac] 注: 某些输入文件使用了未经检查或不安全的操作。
    [javac] 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。

jar:
    [mkdir] Created dir: /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying 9 files to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-app-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-common-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-core-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-hs-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-hs-plugins-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3-tests.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-jobclient-2.7.3-tests.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-jobclient-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-client-shuffle-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-mapreduce-examples-2.7.3.jar
     [copy] Copying 3 files to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.3-tests.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-common-2.7.3-tests.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-common-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/common/hadoop-nfs-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-nfs-2.7.3.jar
     [copy] Copying 3 files to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/hdfs/hadoop-hdfs-2.7.3-tests.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-hdfs-2.7.3-tests.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/hdfs/hadoop-hdfs-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-hdfs-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/hdfs/hadoop-hdfs-nfs-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-hdfs-nfs-2.7.3.jar
     [copy] Copying 13 files to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-api-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-api-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-applications-distributedshell-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-applications-unmanaged-am-launcher-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-client-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-client-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-common-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-common-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-registry-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-registry-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-server-applicationhistoryservice-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-common-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-server-common-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-server-nodemanager-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-server-resourcemanager-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-server-sharedcachemanager-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-tests-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-server-tests-2.7.3.jar
     [copy] Copying /usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-yarn-server-web-proxy-2.7.3.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/protobuf-java-2.5.0.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/protobuf-java-2.5.0.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/log4j-1.2.17.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/log4j-1.2.17.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/commons-cli-1.2.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/commons-cli-1.2.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/commons-configuration-1.6.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/commons-configuration-1.6.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/commons-lang-2.6.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/commons-lang-2.6.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/commons-collections-3.2.2.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/commons-collections-3.2.2.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/jackson-core-asl-1.9.13.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/jackson-mapper-asl-1.9.13.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/slf4j-log4j12-1.7.10.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/slf4j-api-1.7.10.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/slf4j-api-1.7.10.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/guava-11.0.2.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/guava-11.0.2.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/hadoop-auth-2.7.3.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/hadoop-auth-2.7.3.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/netty-3.6.2.Final.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/netty-3.6.2.Final.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/htrace-core-3.1.0-incubating.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/htrace-core-3.1.0-incubating.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/servlet-api-2.5.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/servlet-api-2.5.jar
     [copy] Copying 1 file to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib
     [copy] Copying /usr/local/hadoop/share/hadoop/common/lib/commons-io-2.4.jar to /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/lib/commons-io-2.4.jar
      [jar] Building jar: /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/hadoop-eclipse-plugin-2.7.3.jar

BUILD SUCCESSFUL
Total time: 14 seconds

根据:
[jar] Building jar: /home/hadoop/hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/hadoop-eclipse-plugin-2.7.3.jar
可知编译的 jar 包,在hadoop2x-eclipse-plugin/build/contrib/eclipse-plugin/ 目录下,只需要将hadoop-eclipse-plugin-2.7.3.jar 复制到 eclipse/plugins 下即可。

完!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值