Last active
August 29, 2015 13:57
-
-
Save winse/9564525 to your computer and use it in GitHub Desktop.
Ant实现run-on-hadoop的功能。先打包jar,然后把jar路径赋值给mapred.jar。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<project basedir="." default="run" name="run-on-hadoop"> | |
<property environment="env"/> | |
<property name="fs.default.name" value="hdfs://192.168.0.205:9000" /> | |
<property name="mapred.job.tracker" value="h205:9001" /> | |
<property name="HADOOP_HOME" value="C:/cygwin/home/Winseliu/hadoop-1.0.0" /> | |
<property name="build.dir" value="build" /> | |
<property name="build.classes" value="bin"/> | |
<!-- DSTAMP TSTAMP TODAY --> | |
<tstamp> | |
<format property="now" pattern="yyyyMMddHHmmss"/> | |
</tstamp> | |
<property name="debuglevel" value="source,lines,vars"/> | |
<property name="target" value="1.6"/> | |
<property name="source" value="1.6"/> | |
<path id="hadoop.userclasspath"> | |
<pathelement location="${HADOOP_HOME}/hadoop-core-1.0.0.jar"/> | |
<fileset dir="${HADOOP_HOME}"> | |
<include name="lib/*.jar"/> | |
</fileset> | |
</path> | |
<path id="runon.classpath"> | |
<pathelement location="bin"/> | |
<path refid="hadoop.userclasspath"/> | |
</path> | |
<target name="init"> | |
<echo message="fs.default.name" /> | |
<mkdir dir="${build.dir}" /> | |
<mkdir dir="${build.classes}"/> | |
<copy includeemptydirs="false" todir="bin"> | |
<fileset dir="src"> | |
<exclude name="**/*.java"/> | |
</fileset> | |
</copy> | |
</target> | |
<target name="clean"> | |
<delete dir="${build.classes}"/> | |
<delete dir="${build.dir}"/> | |
</target> | |
<target depends="clean" name="cleanall"/> | |
<target depends="build-project" name="build"/> | |
<target depends="init" name="build-project"> | |
<echo message="${ant.project.name}: ${ant.file}"/> | |
<echo message="...暂时只考虑需要测试的examples目录..." /> | |
<javac debug="true" debuglevel="${debuglevel}" srcdir="src" destdir="${build.classes}" source="${source}" target="${target}"> | |
<include name="**/examples/*" /> | |
<classpath refid="runon.classpath"/> | |
</javac> | |
</target> | |
<property name="exported.jar" value="${build.dir}/tmp-runonhadoop-${now}.jar"></property> | |
<target name="jar" depends="build" description="Make tmp-run.jar"> | |
<jar jarfile="${exported.jar}" basedir="${build.classes}"> | |
<fileset dir="${build.classes}" includes="**/example/*" /> | |
<exclude name="**/core-site.xml"/> | |
</jar> | |
</target> | |
<target name="FileSystemTest" depends="build"> | |
<java classname="com.winse.hadoop.examples.FileSystemTest" failonerror="true" fork="yes"> | |
<classpath refid="runon.classpath"/> | |
</java> | |
</target> | |
<target name="WordCount" depends="build, jar" > | |
<echo message="...这里就是最重要的点咯!..." /> | |
<java classname="com.winse.hadoop.examples.WordCount" failonerror="true" fork="yes"> | |
<arg line="-fs=${fs.default.name} -jt=${mapred.job.tracker} -Dmapred.jar=${exported.jar} /test/input /test/output"/> | |
<classpath refid="runon.classpath"/> | |
</java> | |
</target> | |
<target name="run" depends="clean, WordCount" /> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment