Skip to content

Latest commit

 

History

History
68 lines (45 loc) · 1.1 KB

README.md

File metadata and controls

68 lines (45 loc) · 1.1 KB

Minimal Bazel project showing how to build a Java project with external Maven dependencies.

Query

Show all Maven dependencies available in the repository

bazel query "@maven//:*"

Show all targets in the project

$ bazel query //...

Build

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 //...

Test

Run all tests

$ bazel test //...

Run tests without using the cache:

$ bazel test --cache_test_results=no //...

Coverage

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>

Use different Java version

https://bazel.build/docs/user-manual#java_runtime_version

build --java_language_version=17
build --java_runtime_version=remotejdk_17

Readings