Use a default exclude filter for JaCoCo in Soong.
Instrumented builds should exclude certain classes from instrumenation
by default. (e.g. JaCoCo itself) Leverage the existing
DefaultJacocoExclusionFilter to do this.
Note: Two different default filters exist now (one for Make and one for
Soong), as they have different wildcard rules.
Test: EMMA_INSTRUMENT=true EMMA_INSTRUMENT_STATIC=true m -j32
TeleService and inspected the resulting temporary jar that was
instrumented to confirm that anything from org/jacoco was excluded.
Bug: 159748844
Change-Id: I5466b0a03957edfbe53971d5d1a7729fdb8337db
diff --git a/java/jacoco.go b/java/jacoco.go
index bce9822..9162161 100644
--- a/java/jacoco.go
+++ b/java/jacoco.go
@@ -25,6 +25,7 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/java/config"
)
var (
@@ -76,7 +77,8 @@
if err != nil {
ctx.PropertyErrorf("jacoco.include_filter", "%s", err.Error())
}
- excludes, err := jacocoFiltersToSpecs(j.properties.Jacoco.Exclude_filter)
+ // Also include the default list of classes to exclude from instrumentation.
+ excludes, err := jacocoFiltersToSpecs(append(j.properties.Jacoco.Exclude_filter, config.DefaultJacocoExcludeFilter...))
if err != nil {
ctx.PropertyErrorf("jacoco.exclude_filter", "%s", err.Error())
}