Merge changes I69f80d12,I40d48644 into main
* changes: Merge META-INF/services/* files in merge_zips -jar Strip META-INF/services from implementation jars when using as header jars
This commit is contained in:
@@ -346,6 +346,9 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
// App module names can be overridden.
|
||||
entries.SetString("LOCAL_MODULE", app.installApkName)
|
||||
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
|
||||
if app.headerJarFile != nil {
|
||||
entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
|
||||
}
|
||||
entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
|
||||
if app.dexJarFile.IsSet() {
|
||||
entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
|
||||
|
@@ -1485,7 +1485,13 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
||||
|
||||
j.implementationJarFile = outputFile
|
||||
if j.headerJarFile == nil {
|
||||
j.headerJarFile = j.implementationJarFile
|
||||
// If this module couldn't generate a header jar (for example due to api generating annotation processors)
|
||||
// then use the implementation jar. Run it through zip2zip first to remove any files in META-INF/services
|
||||
// so that javac on modules that depend on this module don't pick up annotation processors (which may be
|
||||
// missing their implementations) from META-INF/services/javax.annotation.processing.Processor.
|
||||
headerJarFile := android.PathForModuleOut(ctx, "javac-header", jarName)
|
||||
convertImplementationJarToHeaderJar(ctx, j.implementationJarFile, headerJarFile)
|
||||
j.headerJarFile = headerJarFile
|
||||
}
|
||||
|
||||
// enforce syntax check to jacoco filters for any build (http://b/183622051)
|
||||
|
@@ -271,6 +271,12 @@ var (
|
||||
Description: "Check zip alignment",
|
||||
},
|
||||
)
|
||||
|
||||
convertImplementationJarToHeaderJarRule = pctx.AndroidStaticRule("convertImplementationJarToHeaderJar",
|
||||
blueprint.RuleParams{
|
||||
Command: `${config.Zip2ZipCmd} -i ${in} -o ${out} -x 'META-INF/services/**/*'`,
|
||||
CommandDeps: []string{"${config.Zip2ZipCmd}"},
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -633,6 +639,15 @@ func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePa
|
||||
})
|
||||
}
|
||||
|
||||
func convertImplementationJarToHeaderJar(ctx android.ModuleContext, implementationJarFile android.Path,
|
||||
headerJarFile android.WritablePath) {
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: convertImplementationJarToHeaderJarRule,
|
||||
Input: implementationJarFile,
|
||||
Output: headerJarFile,
|
||||
})
|
||||
}
|
||||
|
||||
func TransformJarJar(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
classesJar android.Path, rulesFile android.Path) {
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
|
@@ -135,6 +135,7 @@ func TestHostForDevice(t *testing.T) {
|
||||
|
||||
hostModule := ctx.ModuleForTests("host_module", config.BuildOSCommonTarget.String())
|
||||
hostJavac := hostModule.Output("javac/host_module.jar")
|
||||
hostJavacHeader := hostModule.Output("javac-header/host_module.jar")
|
||||
hostRes := hostModule.Output("res/host_module.jar")
|
||||
|
||||
hostImportModule := ctx.ModuleForTests("host_import_module", config.BuildOSCommonTarget.String())
|
||||
@@ -148,7 +149,7 @@ func TestHostForDevice(t *testing.T) {
|
||||
|
||||
// check classpath of device module with dependency on host_for_device_module
|
||||
expectedClasspath := "-classpath " + strings.Join(android.Paths{
|
||||
hostJavac.Output,
|
||||
hostJavacHeader.Output,
|
||||
hostImportCombined.Output,
|
||||
}.Strings(), ":")
|
||||
|
||||
|
@@ -71,8 +71,8 @@ func TestJavaFuzz(t *testing.T) {
|
||||
}
|
||||
|
||||
baz := result.ModuleForTests("baz", osCommonTarget).Rule("javac").Output.String()
|
||||
barOut := filepath.Join("out", "soong", ".intermediates", "bar", osCommonTarget, "javac", "bar.jar")
|
||||
bazOut := filepath.Join("out", "soong", ".intermediates", "baz", osCommonTarget, "javac", "baz.jar")
|
||||
barOut := filepath.Join("out", "soong", ".intermediates", "bar", osCommonTarget, "javac-header", "bar.jar")
|
||||
bazOut := filepath.Join("out", "soong", ".intermediates", "baz", osCommonTarget, "javac-header", "baz.jar")
|
||||
|
||||
android.AssertStringDoesContain(t, "foo classpath", javac.Args["classpath"], barOut)
|
||||
android.AssertStringDoesContain(t, "foo classpath", javac.Args["classpath"], bazOut)
|
||||
|
Reference in New Issue
Block a user