Fix Java coverage support on Windows by adding coverage_main_class to launch_info (#311)

### Summary

This PR enables Java code coverage to work properly on Windows by adding the `coverage_main_class` to the `launch_info` metadata in `bazel_java_binary.bzl`. Without this addition, Bazel fails to properly instrument and run Java binaries with coverage enabled on Windows platforms.

### Changes

- Added `coverage_main_class` to `launch_info` in `bazel_java_binary.bzl` to explicitly define the main class used during coverage runs.

### Motivation

- Before this fix, attempts to run Java coverage tests on Windows would not produce proper coverage output.
- This is a step toward resolving [bazelbuild/bazel#18839](https://github.com/bazelbuild/bazel/issues/18839).

Closes #311

COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_java/pull/311 from KrishnaM256:master 78942a24d9e34daa2ec9cecd8473dbfbb8c64059
PiperOrigin-RevId: 792108185
Change-Id: Ia29301538eaa3f7ca1195230abb32536dbe52e4f
1 file changed
tree: 3f654c6af5f173b7b66d1d8f896853b3a3c35e04
  1. .bazel_checkout/
  2. .bazelci/
  3. .bcr/
  4. .github/
  5. distro/
  6. examples/
  7. java/
  8. test/
  9. toolchains/
  10. .bazelignore
  11. .bazelrc
  12. .gitignore
  13. AUTHORS
  14. BUILD
  15. CODEOWNERS
  16. CONTRIBUTING.md
  17. LICENSE
  18. MODULE.bazel
  19. README.md
  20. renovate.json
  21. WORKSPACE
  22. WORKSPACE.bzlmod
README.md

rules_java

  • Postsubmit Build status
  • Postsubmit + Current Bazel Incompatible Flags Build status

Java Rules for Bazel https://bazel.build.

Documentation

For a quickstart tutorial, see https://bazel.build/start/java

For slightly more advanced usage, like setting up toolchains or writing your own java-like rules, see https://bazel.build/docs/bazel-and-java

Core Java rules

Add a load like:

load("@rules_java//java:java_library.bzl", "java_library")

to your BUILD / BUILD.bazel / bzl` files

For detailed docs on the core rules, see https://bazel.build/reference/be/java