Ant如何构建Hadoop程序

43次阅读
没有评论

这篇文章给大家分享的是有关 Ant 如何构建 Hadoop 程序的内容。丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,一起跟随丸趣 TV 小编过来看看吧。

1、环境描述

Hadoop 环境:VirtualBox5(三台),CentOS7,Hadoop2.7.1

开发环境:Windows7

2、详细配置 2.1、project 结构一览

Ant 如何构建 Hadoop 程序

2.2、build.xml

?xml version= 1.0  encoding= UTF-8 ? 
 project name= wukong-practice-hadoop2  default= package  basedir= .   
  property name= src.dir.main.java  location= src/main/java / 
  property name= src.dir.main.resources  location= src/main/resources / 
  property name= build.dir  location= build / 
  property name= build.dir.classes  location= build/classes / 
  property file= build.properties / 
  property name= jar.name  value= shell-0.1-snapshot.jar / 
  path id= classpath 
  !-- pathelement location= ${build.dir.classes} / -- 
  path refid= hadoop-classpath / 
  path refid= hadoop-depend-classpath / 
  /path 
  path id= hadoop-classpath 
  fileset dir= ${hadoop.dir}/share/hadoop/common 
  include name= **/*.jar / 
  /fileset 
  fileset dir= ${hadoop.dir}/share/hadoop/hdfs 
  include name= **/*.jar / 
  /fileset 
  fileset dir= ${hadoop.dir}/share/hadoop/mapreduce 
  include name= **/*.jar / 
  /fileset 
  fileset dir= ${hadoop.dir}/share/hadoop/yarn 
  include name= **/*.jar / 
  /fileset 
  /path 
  path id= hadoop-depend-classpath 
  fileset dir= ${hadoop.dir}/share/hadoop/common/lib 
  include name= **/*.jar / 
  /fileset 
  fileset dir= ${hadoop.dir}/share/hadoop/hdfs/lib 
  include name= **/*.jar / 
  /fileset 
  fileset dir= ${hadoop.dir}/share/hadoop/mapreduce/lib 
  include name= **/*.jar / 
  /fileset 
  fileset dir= ${hadoop.dir}/share/hadoop/yarn/lib 
  include name= **/*.jar / 
  /fileset 
  /path 
  target name= info 
  echo build wukong-practice-hadoop2.... /echo 
  echo hadoop-path: ${hadoop.path} /echo 
  /target 
  target name= clean 
  delete dir= ${build.dir}/** / 
  /target 
  target name= compile  depends= clean 
  mkdir dir= ${build.dir.classes} / 
  copy todir= ${build.dir.classes}  verbose= true 
  fileset dir= ${src.dir.main.resources} 
  exclude name= META-INF/** / 
  /fileset 
  /copy 
  javac srcdir= ${src.dir.main.java}  destdir= ${build.dir.classes} 
 source= 1.7  target= 1.7  encoding= ${compile.encoding} 
 classpathref= classpath  includeantruntime= false 
  !-- classpath refid= classpath / -- 
  /javac 
  /target 
  target name= package  depends= compile 
  pathconvert property= jar.classpath  pathsep=    refid= classpath 
  map from= ${hadoop.dir}  to= ${hadoop.dir.linux} / 
  /pathconvert 
  !-- pathconvert property= jar.classpath  pathsep=   
  mapper 
  chainedmapper 
  flattenmapper/ 
  globmapper from= *  to= lib/* / 
  /chainedmapper 
  /mapper 
  path refid= classpath / 
  /pathconvert -- 
  jar destfile= ${build.dir}/${jar.name}  basedir= ${build.dir.classes} 
  !--manifest= ${src.main.resources}/META-INF/MANIFEST.MF -- 
  manifest 
  attribute name= Main-Class  value= band.wukong.practice.hadoop2.Commander / 
  attribute name= Class-Path  value= ${jar.classpath} / 
  /manifest 
  /jar 
  /target 
 /project

2.3、build.properties

version=0.1.0
compile.encoding=UTF-8
hadoop.dir=D:/Lab/lib/hadoop/hadoop-2.7.1
hadoop.dir.linux=/user/wukong/local/hadoop-2.7.1

2.4、看一眼生成的 MANIFEST.MF

Ant 如何构建 Hadoop 程序

3、运行示例

Ant 如何构建 Hadoop 程序

感谢各位的阅读!关于“Ant 如何构建 Hadoop 程序”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!