From 7b60cdd6e5d81ae6e929d61898f4faefb1ddb8e2 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 21 Dec 2017 13:52:58 -0800 Subject: [PATCH] Strip module-info.class files when combining jars Combining static jars from dependencies may bring in module-info.class files, which don't make sense once multiple modules have been combined, and sometimes confuse downstream tools like desugar. Strip them out like make does when combining jars. Test: m checkbuild Change-Id: I560c5acfcc6e1be9adf604c22cf200581f92f702 --- java/builder.go | 4 ++++ java/java.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/java/builder.go b/java/builder.go index dd0d927dd..56c7b3300 100644 --- a/java/builder.go +++ b/java/builder.go @@ -383,6 +383,10 @@ func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePa } } + // Remove any module-info.class files that may have come from prebuilt jars, they cause problems + // for downstream tools like desugar. + jarArgs = append(jarArgs, "-stripFile module-info.class") + if stripDirs { jarArgs = append(jarArgs, "-D") } diff --git a/java/java.go b/java/java.go index 302bf78a5..dbf202a00 100644 --- a/java/java.go +++ b/java/java.go @@ -781,6 +781,9 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path if len(jars) == 1 && !manifest.Valid() { // Optimization: skip the combine step if there is nothing to do + // TODO(ccross): this leaves any module-info.class files, but those should only come from + // prebuilt dependencies until we support modules in the platform build, so there shouldn't be + // any if len(jars) == 1. outputFile = jars[0] } else { combinedJar := android.PathForModuleOut(ctx, "combined", jarName)