summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-11-18 21:01:40 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-11-18 21:01:40 +0000
commite99f07cec965fe11f1116b87cd8235ae8434b2f8 (patch)
treeb21b83baf2607555b2a389a47ecab9b5e8b03fa6 /java
parent8cf741ab02dc2feb07e843232d897ed0413a9c39 (diff)
parente4f34886916e5ef36abe8346829dec51020ae0f0 (diff)
Merge "Don't use DirectlyInAnyApex to enable dex and coverage" into main
Diffstat (limited to 'java')
-rw-r--r--java/base.go24
-rw-r--r--java/testing.go1
2 files changed, 10 insertions, 15 deletions
diff --git a/java/base.go b/java/base.go
index 427c28c52..3bf2e23d8 100644
--- a/java/base.go
+++ b/java/base.go
@@ -766,7 +766,8 @@ func (j *Module) shouldInstrumentInApex(ctx android.BaseModuleContext) bool {
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
isJacocoAgent := ctx.ModuleName() == "jacocoagent"
- if j.DirectlyInAnyApex() && !isJacocoAgent && !apexInfo.IsForPlatform() {
+ compileDex := Bool(j.dexProperties.Compile_dex) || Bool(j.properties.Installable)
+ if compileDex && !isJacocoAgent && !apexInfo.IsForPlatform() {
if !inList(ctx.ModuleName(), config.InstrumentFrameworkModules) {
return true
} else if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
@@ -1735,20 +1736,10 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
completeStaticLibsImplementationJarsToCombine := completeStaticLibsImplementationJars
- // Enable dex compilation for the APEX variants, unless it is disabled explicitly
- compileDex := Bool(j.dexProperties.Compile_dex)
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
- if j.DirectlyInAnyApex() && !apexInfo.IsForPlatform() {
- if j.dexProperties.Compile_dex == nil {
- compileDex = true
- }
- if j.deviceProperties.Hostdex == nil {
- j.deviceProperties.Hostdex = proptools.BoolPtr(true)
- }
- }
- if Bool(j.properties.Installable) {
- compileDex = true
- }
+
+ // Enable dex compilation for the APEX variants, unless it is disabled explicitly
+ compileDex := Bool(j.dexProperties.Compile_dex) || Bool(j.properties.Installable)
if j.shouldInstrument(ctx) && (!ctx.Device() || compileDex) {
instrumentedOutputFile := j.instrument(ctx, flags, outputFile, jarName, specs)
@@ -2331,7 +2322,10 @@ func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret
"stable.core.platform.api.stubs",
"stub-annotations", "private-stub-annotations-jar",
"core-lambda-stubs",
- "core-generated-annotation-stubs":
+ "core-generated-annotation-stubs",
+ // jacocoagent only uses core APIs, but has to specify a non-core sdk_version so it can use
+ // a prebuilt SDK to avoid circular dependencies when it statically included in the bootclasspath.
+ "jacocoagent":
return javaCore, true
case android.SdkPublic.DefaultJavaLibraryName():
return javaSdk, true
diff --git a/java/testing.go b/java/testing.go
index 988514dea..cb3245ba7 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -190,6 +190,7 @@ var PrepareForTestWithJacocoInstrumentation = android.GroupFixturePreparers(
"//apex_available:anyapex",
"//apex_available:platform",
],
+ compile_dex: true,
}
`)),
)