From 4c4c02400f0a70bee514bbee77071b5e17300c2e Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 21 Oct 2019 14:53:15 +0900 Subject: [PATCH] add stem property to java modules java_library, java_import and dex_import now support stem property to set the output file name. Bug: 139391334 Test: m Merged-In: I11146badf558e524a973806114b9cb1344db4a6e (cherry picked from commit 62c7829595c0df53e96addcd347c11ac01012eee) Change-Id: I11146badf558e524a973806114b9cb1344db4a6e --- java/java.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/java/java.go b/java/java.go index be48256af..99867c893 100644 --- a/java/java.go +++ b/java/java.go @@ -274,6 +274,9 @@ type CompilerDeviceProperties struct { // otherwise provides defaults libraries to add to the bootclasspath. System_modules *string + // set the name of the output + Stem *string + UncompressDex bool `blueprint:"mutated"` IsSDKLibrary bool `blueprint:"mutated"` } @@ -1600,7 +1603,8 @@ func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bo } func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { - j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", ctx.ModuleName()+".jar") + j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", + proptools.StringDefault(j.deviceProperties.Stem, ctx.ModuleName())+".jar") j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary j.dexpreopter.isInstallable = Bool(j.properties.Installable) j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter) @@ -1924,6 +1928,9 @@ type ImportProperties struct { // if set to true, run Jetifier against .jar file. Defaults to false. Jetifier *bool + + // set the name of the output + Stem *string } type Import struct { @@ -1966,7 +1973,7 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) { func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { jars := android.PathsForModuleSrc(ctx, j.properties.Jars) - jarName := ctx.ModuleName() + ".jar" + jarName := proptools.StringDefault(j.properties.Stem, ctx.ModuleName()) + ".jar" outputFile := android.PathForModuleOut(ctx, "combined", jarName) TransformJarsToJar(ctx, outputFile, "for prebuilts", jars, android.OptionalPath{}, false, j.properties.Exclude_files, j.properties.Exclude_dirs) @@ -2000,7 +2007,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs) if Bool(j.properties.Installable) { ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), - ctx.ModuleName()+".jar", outputFile) + jarName, outputFile) } } @@ -2112,6 +2119,9 @@ func ImportFactoryHost() android.Module { type DexImportProperties struct { Jars []string `android:"path"` + + // set the name of the output + Stem *string } type DexImport struct { @@ -2145,7 +2155,8 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.PropertyErrorf("jars", "exactly one jar must be provided") } - j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", ctx.ModuleName()+".jar") + j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", + proptools.StringDefault(j.properties.Stem, ctx.ModuleName())+".jar") j.dexpreopter.isInstallable = true j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)