Add exclude_files and exclude_dirs properties to java_import
Prebuilt jars sometime contain files that we don't want. In Make we would delete everything in META-INF when importing jars, but that caused problems when there were necessary files in there, so we added LOCAL_DONT_DELETE_JAR_META_INF. Soong does the opposite, keeping everything by default. Add properties to allow explicitly stripping unwanted files instead. Bug: 111389216 Test: m checkbuild Change-Id: I6d07f519ebc7d0e1bf0af93416bb569e3c2b1500
This commit is contained in:
@@ -318,7 +318,8 @@ func TransformResourcesToJar(ctx android.ModuleContext, outputFile android.Writa
|
||||
}
|
||||
|
||||
func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePath, desc string,
|
||||
jars android.Paths, manifest android.OptionalPath, stripDirs bool, dirsToStrip []string) {
|
||||
jars android.Paths, manifest android.OptionalPath, stripDirEntries bool, filesToStrip []string,
|
||||
dirsToStrip []string) {
|
||||
|
||||
var deps android.Paths
|
||||
|
||||
@@ -328,22 +329,19 @@ func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePa
|
||||
deps = append(deps, manifest.Path())
|
||||
}
|
||||
|
||||
if dirsToStrip != nil {
|
||||
for _, dir := range dirsToStrip {
|
||||
jarArgs = append(jarArgs, "-stripDir ", dir)
|
||||
}
|
||||
for _, dir := range dirsToStrip {
|
||||
jarArgs = append(jarArgs, "-stripDir ", dir)
|
||||
}
|
||||
|
||||
for _, file := range filesToStrip {
|
||||
jarArgs = append(jarArgs, "-stripFile ", file)
|
||||
}
|
||||
|
||||
// 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")
|
||||
|
||||
// Remove any kotlin-reflect related files
|
||||
// TODO(pszczepaniak): Support kotlin-reflect
|
||||
jarArgs = append(jarArgs, "-stripFile \"*.kotlin_module\"")
|
||||
jarArgs = append(jarArgs, "-stripFile \"*.kotlin_builtin\"")
|
||||
|
||||
if stripDirs {
|
||||
if stripDirEntries {
|
||||
jarArgs = append(jarArgs, "-D")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user