Move jarjar repackage action before combine action
With this change, the jarjar repackage actions are only on the local classes of each module instead of the combined jar that contains the static libs. The static libs don't need jarjar repackage action on this module level because it has been repackaged when building itself. This change also removes the skip_jarjar_repackage property since it's incompatible with this change. Actually skipping jarjar repackage on a dep may result in incomplete repackage on the module output. Test: CI and observing the build time of SystemUIGoogle Bug: 328067025 Ignore-AOSP-First: Will cp to aosp (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:78ffdd47a658dec4bf79e63d11a5f0f3b94876a4) Merged-In: I476d959af025c46d2ba6d3f48ea378a086666a33 Change-Id: I476d959af025c46d2ba6d3f48ea378a086666a33
This commit is contained in:
committed by
Android Build Cherrypicker Worker
parent
f16c5a0a7d
commit
ddb2ee512c
32
java/base.go
32
java/base.go
@@ -94,9 +94,6 @@ type CommonProperties struct {
|
||||
// if not blank, used as prefix to generate repackage rule
|
||||
Jarjar_prefix *string
|
||||
|
||||
// if set to true, skip the jarjar repackaging
|
||||
Skip_jarjar_repackage *bool
|
||||
|
||||
// If not blank, set the java version passed to javac as -source and -target
|
||||
Java_version *string
|
||||
|
||||
@@ -1103,7 +1100,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
jarjarProviderData := j.collectJarJarRules(ctx)
|
||||
if jarjarProviderData != nil {
|
||||
android.SetProvider(ctx, JarJarProvider, *jarjarProviderData)
|
||||
if !proptools.Bool(j.properties.Skip_jarjar_repackage) {
|
||||
text := getJarJarRuleText(jarjarProviderData)
|
||||
if text != "" {
|
||||
ruleTextFile := android.PathForModuleOut(ctx, "repackaged-jarjar", "repackaging.txt")
|
||||
@@ -1111,7 +1107,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
j.repackageJarjarRules = ruleTextFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)
|
||||
|
||||
@@ -1294,10 +1289,12 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
return
|
||||
}
|
||||
|
||||
kotlinJarPath := j.repackageFlagsIfNecessary(ctx, kotlinJar.OutputPath, jarName, "kotlinc")
|
||||
|
||||
// Make javac rule depend on the kotlinc rule
|
||||
flags.classpath = append(classpath{kotlinHeaderJar}, flags.classpath...)
|
||||
|
||||
kotlinJars = append(kotlinJars, kotlinJar)
|
||||
kotlinJars = append(kotlinJars, kotlinJarPath)
|
||||
kotlinHeaderJars = append(kotlinHeaderJars, kotlinHeaderJar)
|
||||
|
||||
// Jar kotlin classes into the final jar after javac
|
||||
@@ -1377,6 +1374,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
for idx, shardSrc := range shardSrcs {
|
||||
classes := j.compileJavaClasses(ctx, jarName, idx, shardSrc,
|
||||
nil, flags, extraJarDeps)
|
||||
classes = j.repackageFlagsIfNecessary(ctx, classes, jarName, "javac-"+strconv.Itoa(idx))
|
||||
jars = append(jars, classes)
|
||||
}
|
||||
}
|
||||
@@ -1389,11 +1387,13 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
for idx, shardSrcJars := range shardSrcJarsList {
|
||||
classes := j.compileJavaClasses(ctx, jarName, startIdx+idx,
|
||||
nil, shardSrcJars, flags, extraJarDeps)
|
||||
classes = j.repackageFlagsIfNecessary(ctx, classes, jarName, "javac-"+strconv.Itoa(startIdx+idx))
|
||||
jars = append(jars, classes)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
classes := j.compileJavaClasses(ctx, jarName, -1, uniqueJavaFiles, srcJars, flags, extraJarDeps)
|
||||
classes = j.repackageFlagsIfNecessary(ctx, classes, jarName, "javac")
|
||||
jars = append(jars, classes)
|
||||
}
|
||||
if ctx.Failed() {
|
||||
@@ -1552,16 +1552,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
}
|
||||
}
|
||||
|
||||
// Automatic jarjar rules propagation
|
||||
if j.repackageJarjarRules != nil {
|
||||
repackagedJarjarFile := android.PathForModuleOut(ctx, "repackaged-jarjar", jarName).OutputPath
|
||||
TransformJarJar(ctx, repackagedJarjarFile, outputFile, j.repackageJarjarRules)
|
||||
outputFile = repackagedJarjarFile
|
||||
if ctx.Failed() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Check package restrictions if necessary.
|
||||
if len(j.properties.Permitted_packages) > 0 {
|
||||
// Time stamp file created by the package check rule.
|
||||
@@ -2686,6 +2676,16 @@ func getJarJarRuleText(provider *JarJarProviderData) string {
|
||||
return result
|
||||
}
|
||||
|
||||
// Repackage the flags if the jarjar rule txt for the flags is generated
|
||||
func (j *Module) repackageFlagsIfNecessary(ctx android.ModuleContext, infile android.WritablePath, jarName, info string) android.WritablePath {
|
||||
if j.repackageJarjarRules == nil {
|
||||
return infile
|
||||
}
|
||||
repackagedJarjarFile := android.PathForModuleOut(ctx, "repackaged-jarjar", info+jarName)
|
||||
TransformJarJar(ctx, repackagedJarjarFile, infile, j.repackageJarjarRules)
|
||||
return repackagedJarjarFile
|
||||
}
|
||||
|
||||
func addPlugins(deps *deps, pluginJars android.Paths, pluginClasses ...string) {
|
||||
deps.processorPath = append(deps.processorPath, pluginJars...)
|
||||
deps.processorClasses = append(deps.processorClasses, pluginClasses...)
|
||||
|
Reference in New Issue
Block a user