HBase is compiled using Maven. You must use Maven 3.x. To check your Maven version, run the command mvn -version.
Starting with HBase 1.0 you must use Java 7 or later to build from source code. See Table 2.1, “Java” for more complete information about supported JDK versions.
All commands are executed from the local HBase project directory.
The simplest command to compile HBase from its java source code is to use
package target, which builds JARs with the compiled
mvn package -DskipTests
Or, to clean up before compiling:
mvn clean package -DskipTests
With Eclipse set up as explained above in Section 18.3.1, “Eclipse”, you can also use the command in Eclipse. To create the full installable HBase package takes a little bit more work, so read on.
compile target does not create the JARs with the compiled
mvn clean compile
As of 0.96, Apache HBase supports building against Apache Hadoop versions: 1.0.3, 2.0.0-alpha and 3.0.0-SNAPSHOT. By default, in 0.96 and earlier, we will build with Hadoop-1.0.x. As of 0.98, Hadoop 1.x is deprecated and Hadoop 2.x is the default. To change the version to build against, add a hadoop.profile property when you invoke mvn:
mvn -Dhadoop.profile=1.0 ...
The above will build against whatever explicit hadoop 1.x version we have in
pom.xml as our '1.0' version. Tests may not all pass so
you may need to pass
-DskipTests unless you are inclined to fix the
You will see ERRORs like the above title if you pass the default profile; e.g. if you pass hadoop.profile=1.1 when building 0.96 or hadoop.profile=2.0 when building hadoop 0.98; just drop the hadoop.profile stipulation in this case to get your build to run again. This seems to be a maven pecularity that is probably fixable but we've not spent the time trying to figure it.
Similarly, for 3.0, you would just replace the profile value. Note that Hadoop-3.0.0-SNAPSHOT does not currently have a deployed maven artificat - you will need to build and install your own in your local maven repository if you want to run against this profile.
In earilier versions of Apache HBase, you can build against older versions of Apache Hadoop, notably, Hadoop 0.22.x and 0.23.x. If you are running, for example HBase-0.94 and wanted to build against Hadoop 0.23.x, you would run with:
mvn -Dhadoop.profile=22 ...
You may need to change the protobuf definitions that reside in the
hbase-protocol module or other modules.
The protobuf files are located
hbase-protocol/src/main/protobuf. For the change to be
effective, you will need to regenerate the classes. You can use maven profile
compile-protobuf to do this.
mvn compile -Pcompile-protobuf
You may also want to define
protoc.path for the protoc
binary, using the following command:
mvn compile -Pcompile-protobuf -Dprotoc.path=/opt/local/bin/protoc
hbase-protocol/README.txt for more details.
You can build a tarball without going through the release process described in Section 18.5, “Releasing Apache HBase”, by running the following command:
mvn -DskipTests clean install && mvn -DskipTests package assembly:single
The distribution tarball is built in
If you see
Unable to find resource 'VM_global_library.vm', ignore
it. Its not an error. It is officially
-Psnappy to trigger the
hadoop-snappy maven profile
for building Google Snappy native libraries into HBase. See also Section D.3.1.5, “Install Snappy Support”