Minimal Bazel project showing how to build a Java project with external Maven dependencies.
Show all Maven dependencies available in the repository
bazel query "@maven//:*"
Show all targets in the project
$ bazel query //...
Build the main binary
$ bazel build //src/main/java/com/example:main
$ bazel-bin/src/main/java/com/example/main
Build all targets
$ bazel build //...
Run all tests
$ bazel test //...
Run tests without using the cache:
$ bazel test --cache_test_results=no //...
Record test coverage. Disable remote execution if the toolchain used doesn't provide the tools e.g. GCov.
$ apt install lcov
$ bazel coverage --nocache_test_results --strategy=CoverageReport=local //...
$ genhtml --output genhtml <path-to-the-coverage.data-file>
https://bazel.build/docs/user-manual#java_runtime_version
build --java_language_version=17
build --java_runtime_version=remotejdk_17