Bazel Tips and Tricks


Install Bazel

sudo apt-get install bazel
sudo apt-get install --only-upgrade bazel

Bazel Tips

  • Use bash or zsh command completion

Bazel build

  • –keep_going
  • –nobuild

–compilation_mode (fastbuild|opt|dbg) (-c)

  • fastbuild means build as fast as possible: generate minimal debugging information (-gmlt -Wl,-S), and don’t optimize. This is the default. Note: -DNDEBUG will not be set.
  • opt means build with optimization enabled and with assert() calls disabled (-O2 -DNDEBUG). Debugging information will not be generated in opt mode.

Bazel Query

  • list all build targets available in the current directory
    • bazel query :* –output=build

Bazel test

  • Use --test_filter to run a single test class or test method
    • -test_filter=TestClass, -test_filter=TestClass#testMethod
  • --java_debug: causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test
  • --cache_test_results=no
  • --test_arg

Common params

  • --jvmopt="-Xmx10G"

:all VS :*

  • :all: Match all rules in the specified packages.
  • :* or :all-targets: Match all targets (rules and files) in the specified packages.
  • //foo/...:all or //foo/...: Matches all rules in all packages beneath directory ‘foo’.

IntelliJ Bazel Plugin

IntelliJ Bazel Plugin - The latest version may be not supported yet. We may have to download the older version - Check what versions are supported for IntelliJ IDEA

How to manage and remove directories from project in IntelliJ? - Use the Bazel > Project > Open Project View File menu.

Labels

adsense (5) Algorithm (69) Algorithm Series (35) Android (7) ANT (6) bat (8) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) Java (186) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)