hadoop1.2.1 eclipse plugin ant build

linux安装
1.下载hadoop1.2.1
http://mirror.esocc.com/apache/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz

2.解压hadoop1.2.1([color=red]注意:我hadoop-1.2.1的安装根目录为/soft/hadoop-1.2.1,安装路径不同下面注意修改[/color])
tar -zxvf hadoop-1.2.1.tar.gz

3.jdk安装配置(略过)
[color=red]注意:最好使用jdk1.6[/color]

4.安装eclipse(略过)
[color=red]注意:eclipse3.6.1(Centos 6.4自带eclipse),eclipse3.7编译会出错,笔者已经试过[/color]

5.导入eclipse-plugin项目
导入/soft/hadoop-1.2.1/src/contrib/eclipse-plugin项目

6.导入项目需要的jar
[img]http://dl2.iteye.com/upload/attachment/0091/3817/e216c021-7e34-3d70-acd1-b39abaf898e7.jpg[/img]

7.配置build.properties,增加eclipse.home和version,可以复制,替换build.properties

# Licensed 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.


output.. = bin/
bin.includes = META-INF/,\
plugin.xml,\
resources/,\
classes/,\
classes/,\
lib/

#add eclipse.home and hadoop version
eclipse.home=/usr/lib/eclipse
version=1.2.1


8.修改build.xml
a.搜索<path id="eclipse-sdk-jars">,在这个path里加入编译时hadoop需要的jar,可以直接复制替换原来的eclipse-sdk-jars的path标签

<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>

<!-- 增加 -->
<!--build need hadoop classes file.-->
<fileset dir="../../../">
<include name="hadoop*.jar"/>
</fileset>
</path>


b.搜索<target name="jar" depends="compile" unless="skip.contrib">,将2个copy标签注释,可以复制直接替换原来的compile的target

<!-- Override jar target to specify manifest -->
<target name="jar" depends="compile" unless="skip.contrib">
<mkdir dir="${build.dir}/lib"/>
<!-- 注释 -->
<!--
<copy file="${hadoop.root}/build/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/>
<copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/>
-->
<!-- 增加 -->
<copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-cli-${commons-cli.version}.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>


9.ant编译
a.在eclipse中点击Window->Show View->Other->Ant->Ant
b.将build.xml用鼠标拖到Ant视图
c.点Ant视图的绿色run图标
如图:

[img]http://dl2.iteye.com/upload/attachment/0091/3858/8c53edd8-a64c-3d38-920b-2a6eeb66935e.jpg[/img]

10.编译完成
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值