注意,不要下载最新版,下载指定版本 http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.tar.gz
解压缩
[root@hadron ~]# cd apache-ant-1.9.4/
[root@hadron apache-ant-1.9.4]# ll
总用量 380
drwxr-xr-x 2 root root 4096 4月 30 2014 bin
drwxr-xr-x 3 root root 4096 4月 30 2014 etc
-rw-r--r-- 1 root root 11253 4月 30 2014 fetch.xml
-rw-r--r-- 1 root root 4445 4月 30 2014 get-m2.xml
-rw-r--r-- 1 root root 126 4月 30 2014 INSTALL
-rw-r--r-- 1 root root 92261 4月 30 2014 KEYS
drwxr-xr-x 2 root root 4096 4月 30 2014 lib
-rw-r--r-- 1 root root 15289 4月 30 2014 LICENSE
drwxr-xr-x 8 root root 4096 4月 30 2014 manual
-rw-r--r-- 1 root root 305 4月 30 2014 NOTICE
-rw-r--r-- 1 root root 4119 4月 30 2014 README
-rw-r--r-- 1 root root 225057 4月 30 2014 WHATSNEW
[root@hadron apache-ant-1.9.4]#
[root@hadron ~]# git clone https://github.com/apache/zookeeper.git
正克隆到 'zookeeper'...
remote: Counting objects: 35618, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 35618 (delta 0), reused 5 (delta 0), pack-reused 35606
接收对象中: 100% (35618/35618), 28.06 MiB | 81.00 KiB/s, done.
处理 delta 中: 100% (23152/23152), done.
您在 /var/spool/mail/root 中有新邮件
[root@hadron ~]# cd zookeeper/
[root@hadron zookeeper]# ll
总用量 160
drwxr-xr-x 2 root root 4096 7月 26 09:45 bin
-rw-r--r-- 1 root root 82419 7月 26 09:45 build.xml
drwxr-xr-x 2 root root 4096 7月 26 09:45 conf
drwxr-xr-x 4 root root 4096 7月 26 09:45 docs
-rw-r--r-- 1 root root 1709 7月 26 09:45 ivysettings.xml
-rw-r--r-- 1 root root 4132 7月 26 09:45 ivy.xml
-rw-r--r-- 1 root root 11358 7月 26 09:45 LICENSE.txt
-rw-r--r-- 1 root root 170 7月 26 09:45 NOTICE.txt
-rw-r--r-- 1 root root 1347 7月 26 09:45 README_packaging.txt
-rw-r--r-- 1 root root 1636 7月 26 09:45 README.txt
drwxr-xr-x 7 root root 4096 7月 26 09:45 src
-rw-r--r-- 1 root root 21462 7月 26 09:45 zk-merge-pr.py
[root@hadron zookeeper]#
[root@hadron zookeeper]# cat README_packaging.txt
README file for Packaging Notes
Requirement
-----------
ant (recommended version 1.9.4 or later for concurrent JUnit test execution)
gcc, cppunit and python-setuptools are required to build
C and python bindings.
On RHEL machine:
yum install cppunit
yum install python-setuptools
On Ubuntu:
apt-get --install cppunit
apt-get --install python-setuptools
Package build command
---------------------
The ZooKeeper project publishes releases as tarballs. For ZooKeeper packages
specific to your OS (such as rpm and deb), consider using Apache Bigtop:
http://bigtop.apache.org/
Command to build tarball package: ant tar
zookeeper-<version>.tar.gz tarball file structure layout
/bin - User executable
/sbin - System executable
/libexec - Configuration boot trap script
/lib - Library dependencies
/docs - Documents
/share/zookeeper - Project files
Command to build tarball package with native components: ant package-native tar
zookeeper-<version>-lib.tar.gz tarball file structure layout
/bin - User executable
/lib - Native libraries
/include/zookeeper - Native library headers
[root@hadron ~]# yum install -y cppunit
[root@hadron ~]# yum install -y python-setuptools
(1)初次编译
[root@hadron zookeeper]# /root/apache-ant-1.9.4/bin/ant tar
Buildfile: /root/zookeeper/build.xml
init:
[mkdir] Created dir: /root/zookeeper/build/classes
[mkdir] Created dir: /root/zookeeper/build/lib
[mkdir] Created dir: /root/zookeeper/build/package/lib
[mkdir] Created dir: /root/zookeeper/build/test/lib
....
....
check-cppunit-configure:
create-cppunit-configure:
[exec] Can't exec "aclocal": 没有那个文件或目录 at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
[exec] autoreconf: failed to run aclocal: 没有那个文件或目录
BUILD FAILED
/root/zookeeper/build.xml:1276: exec returned: 1
Total time: 30 seconds
[root@hadron zookeeper]#
(2)解决缺失依赖
解决问题:Can’t exec “aclocal”: 没有那个文件或目录 at /usr/share/autoconf/Autom4te/FileUtils.pm line 326
[root@hadron ~]# yum install automake
(3)重新编译
[root@hadron zookeeper]# /root/apache-ant-1.9.4/bin/ant tar
Buildfile: /root/zookeeper/build.xml
init:
.....................
输出省略
.....................
compile:
[echo] contrib: queue
[javac] /root/zookeeper/src/recipes/build-recipes.xml:103: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /root/zookeeper/build/recipes/queue/classes
jar:
[echo] recipes: queue
[jar] Building jar: /root/zookeeper/build/recipes/queue/zookeeper-3.6.0-SNAPSHOT-recipes-queue.jar
zookeeperbuildrecipes.package:
[echo] recipes: queue
[mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue
[copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue
package:
[copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue
[mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/test
[copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/test
[mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/src
[copy] Copying 16 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/recipes/queue/src
[copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT
[mkdir] Created dir: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven
[copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven
[copy] Copying 2 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven
[copy] Copying 1 file to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/dist-maven
[copy] Copying 9 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/bin
[copy] Copying 3 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/conf
[copy] Copying 350 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/docs
[copy] Copying 7 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT
[copy] Copying 1104 files to /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT/src
tar:
[tar] Building tar: /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz
BUILD SUCCESSFUL
Total time: 1 minute 27 seconds
您在 /var/spool/mail/root 中有新邮件
[root@hadron zookeeper]#
注意输出信息BUILD SUCCESSFUL,表示编译成功! (4)查看tar包
[root@hadron zookeeper]# ll /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz
-rw-r--r-- 1 root root 18418052 7月 26 11:02 /root/zookeeper/build/zookeeper-3.6.0-SNAPSHOT.tar.gz
[root@hadron zookeeper]#