A repo that mostly follows Crafting Interpreters.
This repository uses Bazel for build and dependency management.
This document assumes that bazelisk is used instead of
Bazel directly. See these instructions for
installing this tool via go.
The entire project can be built with bazelisk build ...:all from the root of the repository.
Dependencies are configured in the WORKSPACE file and the
third_party directory. Dependencies defined in the former (generally as
part of the maven_install rule) and are wrapped in java_library targets in the latter. This
makes their usage throughout the codebase much cleaner.
It is recommended that several tools are also used.
Handles auto-formatting of all BUILD and WORKSPACE files. From the root of the repository,
buildifier -r -lint=fix -v . will fix all files automatically.
This tool should be installed via go install.
Searches for unused dependencies in java_library rules. From the root of the repository,
unused_deps --build_tool=bazelisk ...:all will analyze all relevant targets.
This tool should be installed via go install.
Rewrites BUILD files based on standard commands. Most usages will be copied from the output
of an Unused Deps command.
This tool should be installed via go install.
Automatically formats Java source files according to the Google Java Style Guide. From the root of the repository (and on Linux), the following command will format all Java source files:
bazelisk run src/main/third_party/tools:java_format -- \
--replace $(find ~+ -not -path '*/\.*' -type f -name '*.java')
Unlike the previous tools, this tool can be run without installing anything.