This is a project template for a greenfield Java project. It's named after the Java mascot Duke. Given below are instructions on how to use it.
Prerequisites: Have bazel
installed.
To build for local development on macOS:
# bazel makes a wrapper script around the jar file.
bazel build //:TerminalDuke && ./bazel-bin/TerminalDuke
# or simply
bazel run //:TerminalDuke
# Use bazelisk for M1 Macs (Apple Silicon)
USE_BAZEL_VERSION=ac9353fab161efae4af72e73fbb657a762b3620d bazelisk run //:TerminalDuke
# For QA build, for example, having assertions enabled, build TerminalDukeQA instead
USE_BAZEL_VERSION=ac9353fab161efae4af72e73fbb657a762b3620d bazelisk run //:TerminalDukeQA
To build jar file for deployment purposes:
bazel build //:Duke_deploy.jar
java -jar ./bazel-bin/Duke_deploy.jar
For unit tests:
bazel test --test_output=all //...
For terminal ui tests (text-ui-test
):
cd text-ui-test
./runtest.sh
Use google-java-format:
google-java-format --replace **/*.java # executes recursively
pre-commit
is a python tool that helps to create git pre-commit hook handlers. For this project, it is used to enforce Google Java Style (via google-java-format
) on new commits.
To setup, ensure you have pre-commit
installed, then run:
pre-commit install
This only needs to be executed once, so that pre-commit
can generate the script and write it to .git/hooks/pre-commit
Thereafter, it should be executed right before every commit!