Skip to content

java_single_jar exposes exclude_pattern and forwards --exclude_pattern, but Bazel OSS singlejar doesn’t accept it #343

@bc-lee

Description

@bc-lee

Problem

The exclude_pattern attribute in java_single_jar is forwarded to singlejar as --exclude_pattern. However, the open-source Bazel singlejar implementation does not define that option (e.g. src/tools/singlejar/options.cc).
As a result, exclusion-by-pattern is currently unusable (or fails with an “unknown option” error) in OSS toolchains, e.g.: singlejar_local: Bad command line argument --exclude_pattern.

Proposal

Short term: Deprecate/hide exclude_pattern in OSS rules_java to avoid confusion and build failures.

Long term: Align rules_java and OSS Bazel singlejar by implementing a supported pattern-based exclusion mechanism in OSS singlejar and exposing it cleanly in java_single_jar (preferably globs via a new attribute like exclude_globs).
Use case: excluding specific packages/classes/resources when building a “single jar” because they are provided by the runtime/platform (Android, app servers, shaded runtime libs), to avoid conflicts and reduce output size.

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