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
diff --git a/java/java.go b/java/java.go
index be48256..99867c8 100644
--- a/java/java.go
+++ b/java/java.go
@@ -274,6 +274,9 @@
// 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 (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 @@
// 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) 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 @@
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 @@
type DexImportProperties struct {
Jars []string `android:"path"`
+
+ // set the name of the output
+ Stem *string
}
type DexImport struct {
@@ -2145,7 +2155,8 @@
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)