Skip to content

Bug: Unable to Exclude META-INF/MANIFEST.MF in ZipFilterAction After rules_android v0.6.5 Update #431

@ThomasCJY

Description

@ThomasCJY

Description

Since the update to rules_android v0.6.5, which migrates the ZipFilterAction to use the C++ singlejar implementation instead of the legacy Java implementation, we are unable to successfully exclude the META-INF/MANIFEST.MF file using zip filters.

The new C++ singlejar implementation incorporates logic from the upstream Bazel change (bazelbuild/bazel@1a70d7e). Specifically, the output_jar.cc source file appears to contain logic that persists the META-INF/MANIFEST.MF file in the output JAR, effectively ignoring any defined filter for this specific path:

Relevant code in Bazel: https://github.com/bazelbuild/bazel/blob/1a70d7e5e3d977e054fc18f925f3e7c3fc452370/src/tools/singlejar/output_jar.cc#L68

This change breaks existing build configurations that rely on excluding this manifest file during JAR merging/filtering operations.

Reproduction

The issue can be observed when attempting to filter out META-INF/MANIFEST.MF in a rule using _common.filter_zip_exclude:

Example Code Snippet:

_common.filter_zip_exclude(
    ctx,
    out,
    merged_jar,
    filters = ["META-INF/MANIFEST.MF"] + exclude_filters,
)

Expected Result: The resulting out JAR file should not contain META-INF/MANIFEST.MF.
Actual Result: The resulting out JAR file still contains META-INF/MANIFEST.MF.

Simple Reproduction (Based on Bazel's Code)

Take the existing simple unit test for output_jar in Bazel: https://github.com/bazelbuild/bazel/blob/1a70d7e5e3d977e054fc18f925f3e7c3fc452370/src/tools/singlejar/output_jar_simple_test.cc#L646.

Add a new test case that attempts to filter out the META-INF/MANIFEST.MF entry.

The test case will fail, demonstrating that the exclusion filter is ignored for this specific entry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions