标签:
eclipse
ant1.8.0
hadoop1.2.1 src
步骤
1. 修改/home/hadoop/hadoop-1.2.1/src/contrib/build-contrib.xml
修改hadop.root值为实际的hadoop根目录
<property name="hadoop.root" location="/home/hadoop/hadoop-1.2.1"/>
添加eclipse依赖
<property name="eclipse.home" location="/home/hadoop/eclipse" />
设置版本号
<property name="version" value="1.2.1"/>
启用javac.deprecation
<property name="javac.deprecation" value="on"/>
ant 1.8+ 版本需要额外的设置javac includeantruntime=“on” 参数
2. 修改/home/hadoop/hadoop-1.2.1/src/contrib/eclipse-plugin/build.xml
添加:
<path id="hadoop-jars"> <fileset dir="${hadoop.root}/"> <include name="hadoop-*.jar"/> </fileset> </path>
<path id="classpath"> <pathelement location="${build.classes}"/> <pathelement location="${hadoop.root}/build/classes"/> <path refid="eclipse-sdk-jars"/> <!--添加下面一行--> <path refid="hadoop-jars"/> </path>修改<target name="jar" depends="compile" unless="skip.contrib">
<target name="jar" depends="compile" unless="skip.contrib"> <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-lang-2.4.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/jackson-mapper-asl-1.8.8.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-httpclient-3.0.1.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>3. 修改/home/hadoop/hadoop-1.2.1/src/contrib/eclipse-plugin/META-INF/MANIFEST.MF
修改Bundle-ClassPath: classes为
Bundle-ClassPath: classes/, lib/hadoop-core.jar, lib/commons-cli.jar, lib/commons-httpclient.jar, lib/hadoop-core.jar, lib/jackson-mapper-asl.jar, lib/commons-configuration.jar, lib/commons-lang.jar, lib/jackson-core-asl.jar
4. 运行ant
$ /home/hadoop/apache-ant-1.8.0/bin/ant
成功后会看到如下提示:
[jar] Building jar: /home/hadoop/hadoop-1.2.1/build/contrib/eclipse-plugin/hadoop-eclipse-plugin-1.2.1.jarBUILD SUCCESSFULTotal time: 3 seconds
标签:
原文地址:http://my.oschina.net/xiaoqqq/blog/400771