not logged in | [Login]

Bazel Cookbook

Bazel is Google's own build tool, now publicly available in Beta. Bazel has built-in support for building both client and server software - http://bazel.io

Bazel query cookbook

Graph dependencies

This will require graphviz. Either brew install graphviz or apt-get install graphviz

bazel query --noimplicit_deps --nohost_deps 'deps(//you-project:your-target)' --output graph > graph.in
dot -Tpng < graph.in > graph.png  

Print Maven jar dependencies

bazel query 'kind(maven_jar, //external:*)'

Print all jar dependencies

bazel query --noimplicit_deps --nohost_deps --keep_going \
--output=location "kind(file,deps(kind(java_import,deps(//my-project:all))))"
  
# For just the jars, pump the output to this
<previous query> | sed 's|/BUILD:[0-9]*:[0-9]*: source file [^:]*:|/|'

Bazel build variables

$@ = the output file defined in OUTS.  Use this to reference the output of another rule.
$< = SRCS (the inputs).  The inputs to a rule. Useful in a Genrule's cmd.