使用ant在window下编译不同hadoop版本的eclipse插件包Ant 1)下载 http://ant.apache.org/bindownl...

本文介绍了如何在Windows环境下利用Ant工具编译不同版本的Hadoop-eclipse-plugin插件。首先,下载并配置Ant,接着下载hadoop源代码和hadoop2x-eclipse-plugin源代码,然后在命令行中切换到相应目录执行ant jar命令进行编译。

Ant

 

 

  1)下载

   http://ant.apache.org/bindownload.cgi

   apache-ant-1.9.4-bin.zip

 2)解压到一个盘,如图所示:

   

 3).环境变量的配置

    新建ANT_HOME=E:\ant\apache-ant-1.9.4-bin\apache-ant-1.9.4

    在PATH后面加;%ANT_HOME%\bin

 4)cmd 测试一下是否配置正确

    ant version   如图所示:

 

 

Hadoop

 

 1).下载hadoop包

    hadoop-2.6.0.tar.gz

   解压到本地磁盘,如图所示:

 

 

下载hadoop2x-eclipse-plugin源代码

 1)目前hadoop2的eclipse-plugins源代码由github脱管,下载地址是https://github.com/winghc/hadoop2x-eclipse-plugin,然后在右侧的Download ZIP连接点击下载,如图所示:

    

 

2)下载hadoop2x-eclipse-plugin-master.zip

   解压到本地磁盘,如图所示:

    

 

编译hadoop-eclipse-plugin插件

 

 

   

 1.hadoop2x-eclipse-plugin-master解压在E:盘打开命令行cmd,切换到E:\hadoop\hadoop2x-eclipse-plugin-master\src\contrib\eclipse-plugin 目录,如图所示:

 

     

 

2.执行ant jar

 

 

其中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 default="jar" name="eclipse-plugin">

<property name="name" value="${ant.project.name}" />

<property name="root" value="${basedir}" />

<property name="hadoop.root" location="C:/Users/Administrator/Desktop/hadoop-1.2.0" />

<property name='version' value='1.2.0' />

<property name='eclipse.home' location='C:/My Program/eclipse' />

<property name="build.dir" location="${hadoop.root}/build/contrib/${name}" />

<property name="build.classes" location="${build.dir}/classes" />

<property name="src.dir" location="${root}/src/java" />

<path id="eclipse-sdk-jars">

<fileset dir="${eclipse.home}/plugins/">

<include name="org.eclipse.ui*.jar" />

<include name="org.eclipse.jdt*.jar" />

<include name="org.eclipse.core*.jar" />

<include name="org.eclipse.equinox*.jar" />

<include name="org.eclipse.debug*.jar" />

<include name="org.eclipse.osgi*.jar" />

<include name="org.eclipse.swt*.jar" />

<include name="org.eclipse.jface*.jar" />

<include name="org.eclipse.team.cvs.ssh2*.jar" />

<include name="com.jcraft.jsch*.jar" />

</fileset>

</path>

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

<path id="classpath">

<fileset dir="${hadoop.root}">

<include name="*.jar" />

</fileset>

<path refid="eclipse-sdk-jars" />

</path>

<target name="compile">

<mkdir dir="${build.dir}/classes" />

<javac encoding="ISO-8859-1" srcdir="${src.dir}" includes="**/*.java" destdir="${build.classes}" debug="on" deprecation="off">

<classpath refid="classpath" />

</javac>

</target>

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

<target name="jar" depends="compile">

<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-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-core-asl-1.8.8.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/jackson-mapper-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>

 

</project>

其中MAINIFEST文件内容如下:

Manifest-Version: 1.0

Bundle-ManifestVersion: 2

Bundle-Name: MapReduce Tools for Eclipse

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

Bundle-Version: 0.18

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

Bundle-Localization: plugin

Require-Bundle: org.eclipse.ui,

 org.eclipse.core.runtime,

 org.eclipse.jdt.launching,

 org.eclipse.debug.core,

 org.eclipse.jdt,

 org.eclipse.jdt.core,

 org.eclipse.core.resources,

 org.eclipse.ui.ide,

 org.eclipse.jdt.ui,

 org.eclipse.debug.ui,

 org.eclipse.jdt.debug.ui,

 org.eclipse.core.expressions,

 org.eclipse.ui.cheatsheets,

 org.eclipse.ui.console,

 org.eclipse.ui.navigator,

 org.eclipse.core.filesystem,

 org.apache.commons.logging

Eclipse-LazyStart: true

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

 

Bundle-Vendor: Apache Hadoop

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值