Add Jacoco support
Add support for instrumenting jars with jacoco. Unlike in Make,
Jacoco in Soong is done entirely using jars.
Instrumentation is enabled by EMMA_INSTRUMENT=true, and affects
all apps. If EMMA_INSTRUMENT_FRAMEWORK=true then it also affects
any java libraries listed in InstrumentFrameworkModules.
Bug: 69629238
Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true SKIP_BOOT_JARS_CHECK=true WITH_DEXPREOPT=false
Change-Id: If699715b277529cd7322ffca67c23b0746e1cccd
diff --git a/java/config/config.go b/java/config/config.go
index 3cd2841..49481be 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -28,6 +28,16 @@
DefaultBootclasspathLibraries = []string{"core-oj", "core-libart"}
DefaultSystemModules = "core-system-modules"
DefaultLibraries = []string{"ext", "framework", "okhttp"}
+
+ DefaultJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"}
+
+ InstrumentFrameworkModules = []string{
+ "framework",
+ "telephony-common",
+ "services",
+ "android.car",
+ "android.car7",
+ }
)
func init() {
@@ -74,6 +84,7 @@
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
+ pctx.HostBinToolVariable("Zip2ZipCmd", "zip2zip")
pctx.VariableFunc("DxCmd", func(config interface{}) (string, error) {
if config.(android.Config).IsEnvFalse("USE_D8") {
if config.(android.Config).UnbundledBuild() || config.(android.Config).IsPdkBuild() {
@@ -117,4 +128,6 @@
}
return "", nil
})
+
+ pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
}