Book Description

One of the newer players in the build tool field is Bazel, the open source variant of Google’s powerful internal build tool Blaze. After years of refinement, the first production-ready version, Bazel 1.0, was released in October 2019. Is this tool right for your organization? This report explores the use cases, features, and usability concerns of Bazel, including its benefits and shortcomings.

Author Benjamin Muschko uses concrete Java-based examples to give you a first taste of Bazel’s syntax and functionality. The report also covers advanced features like remote caching and execution. You’ll be able to determine hands-on if Bazel is a good fit for your organization and come away with the knowledge and resources to start using this versatile, polyglot build tool for your project.

  • Set up a Java-based project, compile the source code, and run the application
  • Define dependencies on other packages and external libraries
  • Perform automated tests for Java test code
  • Extend Bazel’s built-in capabilities by custom functionality
  • Improve build performance and scalability through remote caching and execution
  • Execute Bazel projects on continuous integration servers

Table of Contents

  1. Getting Started with Bazel
    1. Introducing Bazel
      1. What Is It?
      2. Why Should I Use It?
    2. Installing Bazel
      1. Installation Options
      2. Using the Bazel Binary Installer
      3. Command-Line Completion
      4. User-Friendly Launcher for Bazel
    3. Bazel Quick Start
      1. Basic Building Blocks
      2. Setting Up a “Hello World” Java Project
      3. Running the Build from the Command Line
      4. Using the Generated Artifacts
      5. The Lifecycle of a Bazel Build
      6. Driving Bazel from the IDE
    4. Dependency Management
      1. Modeling Fine-Grained Package Granularity and Dependencies
      2. Declaring and Using External Dependencies
    5. Executing Automated Tests
    6. Extending Bazel’s Capabilities
      1. Extension Concepts
      2. The Starlark Build Language
      3. Writing a Macro by Example
      4. Writing a Rule by Example
    7. Build Performance and Scalability
      1. Remote Caching
      2. Remote Execution
    8. Executing Bazel Projects on CI Servers
    9. Conclusion