rules_java icon indicating copy to clipboard operation
rules_java copied to clipboard

Coverge support breaks when test has its own dependency on `org.jacoco.*`

Open Silic0nS0ldier opened this issue 1 year ago • 1 comments

As a coverage tool, it is highly unlikely that a library will include a genuine dependency on org.jacoco.*. However;

  • There are no safeguards in place. If this does happen, bazel coverage may just not work. Ideally what I suspect to be a technical limitation would be reported on at compile time.
  • Sometimes third party packages include test dependencies as compile dependencies by mistake. e.g. https://github.com/aliyun/aliyun-openapi-java-sdk/pull/930

Silic0nS0ldier avatar Jul 25 '24 01:07 Silic0nS0ldier

We actually ran into this with Jazzer, which has a legitimate need to depend on JaCoCo during regular execution. Shading helped here: https://github.com/CodeIntelligenceTesting/jazzer/blob/main/third_party/jacoco_internal.BUILD

Bazel has a built-in capability to detect classpath duplication, which I recently wired up to some extent. You could take a look at the test in https://github.com/bazelbuild/bazel/commit/417c6b803db1078d20077068471427c86c016190#diff-61be5294c014a8b30530f4e0801697cf6d8c1181d8e4400164b62ef00c2be0d5 and see whether this setup catches the issue.

fmeum avatar Jul 25 '24 07:07 fmeum