一、前提条件
1、安装好Java JDK 1.6或以上版本;
2、安装好Apache Maven。
如果上述条件准备好之后,下面开始用Maven编译Mahout源码
二、git一份Mahout源码
用下面的命令从 Mahout GitHub 仓库Git(如果你电脑没有安装Git软件,可以参照这个安装《Git安装》)一份代码到本地
git clone git@github.com:apache/mahout.git 或者 git clone https://github.com/apache/mahout.git
下面是具体操作:
[iteblog.com@master ~]$ git clone https://github.com/apache/mahout.git Cloning into mahout... remote: Counting objects: 79725, done. remote: Total 79725 (delta 0), reused 0 (delta 0) Receiving objects: 100% (79725/79725), 39.30 MiB | 3.91 MiB/s, done. Resolving deltas: 100% (42930/42930), done. [iteblog.com@master ~]$ ll total 4 drwxr-xr-x 16 iteblog.com wyp 4096 Sep 15 18:32 mahout
从Mahout GitHub 仓库Git出的源码工程是最新版的,本文Git下来的是1.0-SNAPSHOT。
三、编译
可以用下面的命令编译Mahout:
mvn clean install
如果你直接这样编译,项目将默认依赖hadoop-1.2.1,如果你想修改Hadoop的默认版本,可以用下面的Maven命令:
mvn -Dhadoop2.version=2.2.0 clean install
Mahout自带的源码包里面有许多测试用例,如果你用上面的命令去编译,将会把测试用例一起编译,这将耗费许多的时间,所以如果你最想编译Mahout而忽略测试用例,那么请用下面的命令进行编译
# With hadoop-1.2.1 dependency mvn -DskipTests clean install # With hadoop-2.2.0 dependency mvn -Dhadoop2.version=2.2.0 -DskipTests clean install
上面的命令只是编译了Mahout,如果你想将工程打包,可以用下面的命令进行编译
# With hadoop-1.2.1 dependency mvn clean package # With hadoop-2.2.0 dependency mvn -Dhadoop2.version=2.2.0 clean package
编译的过程需要下载许多的Jar依赖,所以编译的过程依赖你网络的速度,坐在那慢慢等吧。如果一切顺利的话,你将看到如下的输出信息:
[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] Mahout Build Tools ................................ SUCCESS [12.965s] [INFO] Apache Mahout ..................................... SUCCESS [0.394s] [INFO] Mahout Math ....................................... SUCCESS [1:41.687s] [INFO] Mahout MapReduce Legacy ........................... SUCCESS [31.892s] [INFO] Mahout Integration ................................ SUCCESS [16.172s] [INFO] Mahout Examples ................................... SUCCESS [15.344s] [INFO] Mahout Release Package ............................ SUCCESS [0.007s] [INFO] Mahout Math Scala bindings ........................ SUCCESS [36.364s] [INFO] Mahout Spark bindings ............................. SUCCESS [1:22.855s] [INFO] Mahout Spark bindings shell ....................... SUCCESS [18.647s] [INFO] Mahout H2O backend ................................ SUCCESS [39.136s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5:55.963s [INFO] Finished at: Mon Sep 15 18:45:32 CST 2014 [INFO] Final Memory: 90M/694M [INFO] ------------------------------------------------------------------------
那恭喜你了,编程成功,让我们一起进入Mahout 的世界吧!
本博客文章除特别声明,全部都是原创!原创文章版权归过往记忆大数据(过往记忆)所有,未经许可不得转载。
本文链接: 【用Maven编译Mahout工程】(https://www.iteblog.com/archives/1127.html)