1、编译前准备
a) 下载和解压hadoop-1.1.2.tar.gz
b) 下载并配置ant
2、配置
a) 进入hadoop-1.1.2\src\contrib拷贝build-contrib.xml到eclipse-plugin下
2 ) 修改build-contrib.xml
i. 修改为自己的路径:
<propertyname="name" value="${ant.project.name}"/> <propertyname="root"value="D:/JavaDev/hadoop/src/contrib/eclipse-plugin"/> <propertyname="eclipse.home"location="D:/JavaDev/eclipseVsizen/eclipse"/> <propertyname="version" value="1.1.2"/> <propertyname="hadoop.root" location="D:/JavaDev/hadoop"/>
3 修改build.xml
3.1 修改引入文件
<importfile="build-contrib.xml"/>
3.2 修改<mkdir dir="${build.dir}/lib"/>后面部分
<copyfile="${hadoop.root}/build/hadoop-core-${version}.jar"tofile="${build.dir}/lib/hadoop-core.jar"verbose="true"/> <copyfile="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-configuration-1.6.jar"tofile="${build.dir}/lib/commons-configuration-1.6.jar"verbose="true"/> <copyfile="${hadoop.root}/lib/commons-httpclient-3.0.1.jar"tofile="${build.dir}/lib/commons-httpclient-3.0.1.jar"verbose="true"/> <copyfile="${hadoop.root}/lib/commons-lang-2.4.jar"tofile="${build.dir}/lib/commons-lang-2.4.jar"verbose="true"/> <copyfile="${hadoop.root}/lib/jackson-core-asl-1.8.8.jar"tofile="${build.dir}/lib/jackson-core-asl-1.8.8.jar"verbose="true"/> <copyfile="${hadoop.root}/lib/jackson-mapper-asl-1.8.8.jar"tofile="${build.dir}/lib/jackson-mapper-asl-1.8.8.jar"verbose="true"/>
如图:
3.3 添加节点
build.xml文件下添加:
<pathid="hadoop-jars"> <fileset dir="${hadoop.root}/"> <include name="hadoop-*.jar"/> </fileset> </path>
在<path id="classpath">节点内添加
<path refid="hadoop-jars"/>
如图:
4.修改文件 MANIFEST.MF
修改:MANIFEST.MF文件。目录:D:\hadoop-1.1.2\src\contrib\eclipse-plugin\META-INF
Bundle-ClassPath那一栏加入如下信息:
Bundle-ClassPath:classes/, lib/hadoop-core.jar,lib/commons-configuration-1.6.jar,lib/commons-httpclient-3.0.1.jar,lib/commons-lang-2.4.jar,lib/jackson-core-asl-1.8.8.jar,lib/jackson-mapper-asl-1.8.8.jar,lib/commons-cli-1.2.jar
如图:
最后:
右击文件build.xml文件->ant build ,成功后在目录D:\JavaDev\hadoop\build\contrib\eclipse-plugin找到插件