This file contains instructions for building and running Bazel.
Supported platforms:
Java:
Clone the Bazel repo from GitHub:
$ cd $HOME $ git clone https://github.com/google/bazel/
To build Bazel on Ubuntu:
On Ubuntu Trusty (14.04LTS), no OpenJDK 8 is available and the fastest way is to install the Oracle JDK 8:
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer
On Ubuntu Utopic (14.10):
$ sudo apt-get install openjdk-8-jdk
Install required packages:
$ sudo apt-get install libarchive-dev pkg-config
Build Bazel:
$ cd bazel $ ./compile.sh
Using Bazel on Mac OS X requires:
To build Bazel on Mac OS X:
Install required packages:
$ port install protobuf-cpp libarchive
or
$ brew install protobuf libarchive
Build Bazel:
$ cd bazel $ ./compile.sh
Run it
$ ./output/bazel help
The Bazel executable is located at output/bazel
, under the source tree root.
You must run Bazel from within source code tree, which is properly configured for use with Bazel. We call such a tree a workspace directory. Bazel provides a default workspace directory with sample BUILD
files and source code in base_workspace
. The default workspace contains files and directories that must be present in order for Bazel to work. If you want to build from source outside the default workspace directory, copy the entire base_workspace
directory to the new location before adding your BUILD
and source files.
Build a sample Java application:
$ cp -R $HOME/bazel/base_workspace $HOME/my_workspace $ cd $HOME/my_workspace $ $HOME/bazel/output/bazel build //examples/java-native/src/main/java/com/example/myproject:hello-world
The build output is located in $HOME/my_workspace/bazel-bin/examples/java-native/src/main/java/com/example/myproject/
.
Run the sample application:
$ $HOME/my_workspace/bazel-bin/examples/java-native/src/main/java/com/example/myproject/hello-world
For more information, see Getting started.