Fix stem to be propagated to output jar name in java_library

Currently, java_library.stem property is not correctly reflected in the
output jar name in java_library when the module specifies
java_resource_dirs property. This change fixes the unexpected behavior
so that setting the stem property behaves as expected.

Test: go test ./java && m
Bug: 285843207
Change-Id: I0941fcea83c92f4c42ae415aa6ad9125da5cf57b
This commit is contained in:
Jihoon Kang
2023-07-01 00:13:47 +00:00
parent c38523cd33
commit 1bfb6f231e
6 changed files with 46 additions and 8 deletions

View File

@@ -666,8 +666,17 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.aapt.useEmbeddedNativeLibs = a.useEmbeddedNativeLibs(ctx)
a.aapt.useEmbeddedDex = Bool(a.appProperties.Use_embedded_dex)
// Unlike installApkName, a.stem should respect base module name for override_android_app.
// Therefore, use ctx.ModuleName() instead of a.Name().
a.stem = proptools.StringDefault(a.overridableDeviceProperties.Stem, ctx.ModuleName())
// Check if the install APK name needs to be overridden.
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(a.Stem())
// Both android_app and override_android_app module are expected to possess
// its module bound apk path. However, override_android_app inherits ctx.ModuleName()
// from the base module. Therefore, use a.Name() which represents
// the module name for both android_app and override_android_app.
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(
proptools.StringDefault(a.overridableDeviceProperties.Stem, a.Name()))
if ctx.ModuleName() == "framework-res" {
// framework-res.apk is installed as system/framework/framework-res.apk