Merge "Fix stem to be propagated to output jar name in java_library" into main
This commit is contained in:
commit
ef5d8278be
6 changed files with 46 additions and 8 deletions
|
@ -611,6 +611,8 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||
|
||||
a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
|
||||
|
||||
a.stem = proptools.StringDefault(a.overridableDeviceProperties.Stem, ctx.ModuleName())
|
||||
|
||||
ctx.CheckbuildFile(a.proguardOptionsFile)
|
||||
ctx.CheckbuildFile(a.exportPackage)
|
||||
ctx.CheckbuildFile(a.aaptSrcJar)
|
||||
|
|
|
@ -455,11 +455,6 @@ func (a *AndroidApp) getOverriddenPackages() []string {
|
|||
if len(a.overridableAppProperties.Overrides) > 0 {
|
||||
overridden = append(overridden, a.overridableAppProperties.Overrides...)
|
||||
}
|
||||
// When APK name is overridden via PRODUCT_PACKAGE_NAME_OVERRIDES
|
||||
// ensure that the original name is overridden.
|
||||
if a.Stem() != a.installApkName {
|
||||
overridden = append(overridden, a.Stem())
|
||||
}
|
||||
return overridden
|
||||
}
|
||||
|
||||
|
|
11
java/app.go
11
java/app.go
|
@ -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
|
||||
|
|
13
java/base.go
13
java/base.go
|
@ -21,6 +21,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"android/soong/ui/metrics/bp2build_metrics_proto"
|
||||
|
||||
"github.com/google/blueprint/pathtools"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
|
@ -502,6 +503,11 @@ type Module struct {
|
|||
sourceExtensions []string
|
||||
|
||||
annoSrcJars android.Paths
|
||||
|
||||
// output file name based on Stem property.
|
||||
// This should be set in every ModuleWithStem's GenerateAndroidBuildActions
|
||||
// or the module should override Stem().
|
||||
stem string
|
||||
}
|
||||
|
||||
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
|
||||
|
@ -1099,7 +1105,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||
j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
||||
}
|
||||
|
||||
jarName := ctx.ModuleName() + ".jar"
|
||||
jarName := j.Stem() + ".jar"
|
||||
|
||||
var uniqueJavaFiles android.Paths
|
||||
set := make(map[string]bool)
|
||||
|
@ -1897,7 +1903,10 @@ func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersi
|
|||
}
|
||||
|
||||
func (j *Module) Stem() string {
|
||||
return proptools.StringDefault(j.overridableDeviceProperties.Stem, j.Name())
|
||||
if j.stem == "" {
|
||||
panic("Stem() called before stem property was set")
|
||||
}
|
||||
return j.stem
|
||||
}
|
||||
|
||||
func (j *Module) JacocoReportClassesFile() android.Path {
|
||||
|
|
|
@ -676,6 +676,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
j.minSdkVersion = j.MinSdkVersion(ctx)
|
||||
j.maxSdkVersion = j.MaxSdkVersion(ctx)
|
||||
|
||||
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
|
||||
|
||||
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||
if !apexInfo.IsForPlatform() {
|
||||
j.hideApexVariantFromMake = true
|
||||
|
@ -1468,6 +1470,8 @@ func (j *Binary) HostToolPath() android.OptionalPath {
|
|||
}
|
||||
|
||||
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
|
||||
|
||||
if ctx.Arch().ArchType == android.Common {
|
||||
// Compile the jar
|
||||
if j.binaryProperties.Main_class != nil {
|
||||
|
|
|
@ -2351,3 +2351,22 @@ func TestJavaExcludeStaticLib(t *testing.T) {
|
|||
`stable.core.platform.api.stubs`,
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryWithResourcesStem(t *testing.T) {
|
||||
ctx, _ := testJavaWithFS(t, `
|
||||
java_library {
|
||||
name: "foo",
|
||||
java_resource_dirs: ["test-jar"],
|
||||
stem: "test",
|
||||
}
|
||||
`,
|
||||
map[string][]byte{
|
||||
"test-jar/test/resource.txt": nil,
|
||||
})
|
||||
|
||||
m := ctx.ModuleForTests("foo", "android_common")
|
||||
outputs := fmt.Sprint(m.AllOutputs())
|
||||
if !strings.Contains(outputs, "test.jar") {
|
||||
t.Errorf("Module output does not contain expected jar %s", "test.jar")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue