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.