summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/base.go5
-rw-r--r--java/bootclasspath_fragment_test.go20
-rw-r--r--java/config/config.go2
3 files changed, 22 insertions, 5 deletions
diff --git a/java/base.go b/java/base.go
index cf3b3d510..53f0f52c2 100644
--- a/java/base.go
+++ b/java/base.go
@@ -169,6 +169,8 @@ type CommonProperties struct {
Output_params []string
}
+ // If true, then jacocoagent is automatically added as a libs dependency so that
+ // r8 will not strip instrumentation classes out of dexed libraries.
Instrument bool `blueprint:"mutated"`
// If true, then the module supports statically including the jacocoagent
// into the library.
@@ -787,6 +789,9 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} else if j.shouldInstrumentStatic(ctx) {
ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent")
}
+ if j.shouldInstrument(ctx) {
+ ctx.AddVariationDependencies(nil, libTag, "jacocoagent")
+ }
if j.useCompose() {
ctx.AddVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), kotlinPluginTag,
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index f95c83fe7..2bfb255af 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -96,10 +96,22 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testin
}
func TestBootclasspathFragment_Coverage(t *testing.T) {
- prepareForTestWithFrameworkCoverage := android.FixtureMergeEnv(map[string]string{
- "EMMA_INSTRUMENT": "true",
- "EMMA_INSTRUMENT_FRAMEWORK": "true",
- })
+ prepareForTestWithFrameworkCoverage := android.GroupFixturePreparers(
+ android.FixtureMergeEnv(map[string]string{
+ "EMMA_INSTRUMENT": "true",
+ "EMMA_INSTRUMENT_FRAMEWORK": "true",
+ }),
+ // need to mock jacocoagent here to satisfy dependency added for
+ // instrumented libraries at build time
+ android.FixtureAddFile("jacocoagent/Android.bp", []byte(`
+ java_library {
+ name: "jacocoagent",
+ srcs: ["Test.java"],
+ system_modules: "none",
+ sdk_version: "none",
+ }
+ `)),
+ )
prepareWithBp := android.FixtureWithRootAndroidBp(`
bootclasspath_fragment {
diff --git a/java/config/config.go b/java/config/config.go
index 3ca9bad3e..422f86002 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -148,7 +148,7 @@ func init() {
pctx.SourcePathVariable("JavaKytheExtractorJar", "prebuilts/build-tools/common/framework/javac_extractor.jar")
pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime")
- pctx.HostBinToolVariable("GenKotlinBuildFileCmd", "gen-kotlin-build-file.py")
+ pctx.HostBinToolVariable("GenKotlinBuildFileCmd", "gen-kotlin-build-file")
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
pctx.SourcePathVariable("PackageCheckCmd", "build/soong/scripts/package-check.sh")