Skip to content

Allow filtering instrumented classes in JacocoInstrumentationProcessor#29502

Open
Steffeeen wants to merge 1 commit into
bazelbuild:masterfrom
Steffeeen:jacoco-filtering
Open

Allow filtering instrumented classes in JacocoInstrumentationProcessor#29502
Steffeeen wants to merge 1 commit into
bazelbuild:masterfrom
Steffeeen:jacoco-filtering

Conversation

@Steffeeen
Copy link
Copy Markdown

@Steffeeen Steffeeen commented May 9, 2026

Description

This PR allows passing include and exclude lists to the JacocoInstrumentationProcessor to filter which classes get instrumented. The format and behavior is the same as used by JaCoCo. Only classes in the include list get instrumented except if they are in the exclude list. The lists are lists of class names separated by :. The class names use / as a separator instead of .. ? and * are supported as wildcards. If no options are given all classes will be included (again matching the behavior of JaCoCo).

Should I add tests for these changes? That would require refactoring the code a bit and moving the include/exclude logic into a separate method or class.

Motivation

Fixes #28209 and #21520 in combination with bazelbuild/rules_java#356

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

The filtering mechanism is the same as used by JaCoCo. All classes that
are specified in include are instrumented except if they are in exclude.

The matching engine allows using `?` to match any single character and
`*` to match any number of any character. These are the same wildcards
as supported by JaCoCo.
@Steffeeen Steffeeen requested review from a team and lberki as code owners May 9, 2026 12:34
@github-actions github-actions Bot added team-Rules-Java Issues for Java rules awaiting-review PR is awaiting review from an assigned reviewer team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels May 9, 2026
@meisterT meisterT requested a review from c-mita May 11, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts team-Rules-Java Issues for Java rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filtering class files for code coverage in JacocoInstrumentationProcessor.java

1 participant