Fix jacoco-toolchain dependency.

Bazel 0.26 added the `jacocorunner` attribute on `java_toolchain`. Java targets now fail when using the new host java_toolchain because of a dependency cycle:

```
@bazel_tools//tools/jdk:JacocoCoverageRunner
@bazel_tools//tools/jdk:current_java_toolchain
@bazel_tools//tools/jdk:legacy_current_java_toolchain
@bazel_tools//tools/jdk:remote_toolchain
@remote_java_tools_linux//:toolchain
.-> @remote_java_tools_linux//:jacoco_coverage_runner (host)
|   @bazel_tools//tools/jdk:current_java_toolchain (host)
|   @bazel_tools//tools/jdk:legacy_current_java_toolchain (host)
|   @bazel_tools//tools/jdk:remote_toolchain (host)
|   @remote_java_tools_linux//:toolchain (host)
`-- @remote_java_tools_linux//:jacoco_coverage_runner (host)
```

The dependency is happening because `jacocorunner` in `java_toolchain` was declared as a `java_import` which depends on the host `java_toolchain`. The issue was not caught because we only run the java integration tests with `--java_toolchain` built at head. If we had run the tests also with `--host_java_toolchain` the issue would have been caught (see #8530).

This PR does the following:
* Makes `jacocorunner` attribute a `filegroup` instead of a `java_import` to avoid the dependency cycle.
* Converts the type of `jacocoRunner` in `JavaToolchain` from a `TransitiveInfoCollection` to `FilesToRunProvider` to be able to retrieve the executable jar from the `filegroup`.
* Adds testing with `--host_java_toolchain` of the java_tools built as head

This is a blocker for the new java_tools release (https://github.com/bazelbuild/java_tools/issues/8).

Closes #8529.

PiperOrigin-RevId: 250876908
7 files changed
tree: 5453bb1236f0591d90b60a277cc4e9802fdf9e0e
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .bazelrc
  9. .gitattributes
  10. .gitignore
  11. AUTHORS
  12. BUILD
  13. CHANGELOG.md
  14. CODEOWNERS
  15. combine_distfiles.py
  16. combine_distfiles_to_tar.sh
  17. compile.sh
  18. CONTRIBUTING.md
  19. CONTRIBUTORS
  20. distdir.bzl
  21. ISSUE_TEMPLATE.md
  22. LICENSE
  23. README.md
  24. WORKSPACE
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel only rebuilds what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Contributing to Bazel

See CONTRIBUTING.md

Build status

Bazel is released in ‘Beta’. See the product roadmap to learn about the path toward a stable 1.0 release.