Fix instrumentation_for to match LOCAL_INSTRUMENTATION_FOR
The value from instrumentation_for should not go to
aapt2 link --rename-instrumentation-target-package, that should
be the equivalent of LOCAL_MANIFEST_INSTRUMENTATION_FOR. That
property is never used in Make, so it is left unimplemented in
Soong.
Add the module listed in instrumentation_for as a shared library
for javac, but don't import its resources.
Bug: 117804211
Test: m checkbuild
Change-Id: I7f035dc0ecb964a3ca391ae1ca2b87cb0f6a7cec
diff --git a/java/app.go b/java/app.go
index d21b62a..5d25dcf 100644
--- a/java/app.go
+++ b/java/app.go
@@ -318,12 +318,6 @@
}
func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- if String(a.appTestProperties.Instrumentation_for) != "" {
- a.AndroidApp.extraLinkFlags = append(a.AndroidApp.extraLinkFlags,
- "--rename-instrumentation-target-package",
- String(a.appTestProperties.Instrumentation_for))
- }
-
a.generateAndroidBuildActions(ctx)
a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath)
@@ -335,6 +329,12 @@
android.ExtractSourceDeps(ctx, a.testProperties.Test_config_template)
android.ExtractSourcesDeps(ctx, a.testProperties.Data)
a.AndroidApp.DepsMutator(ctx)
+ if a.appTestProperties.Instrumentation_for != nil {
+ // The android_app dependency listed in instrumentation_for needs to be added to the classpath for javac,
+ // but not added to the aapt2 link includes like a normal android_app or android_library dependency, so
+ // use instrumentationForTag instead of libTag.
+ ctx.AddVariationDependencies(nil, instrumentationForTag, String(a.appTestProperties.Instrumentation_for))
+ }
}
func AndroidTestFactory() android.Module {