Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible change: java_output.source_jars will return a Depset instead of a list #18966

Closed
hvadehra opened this issue Jul 18, 2023 · 0 comments
Labels
incompatible-change Incompatible/breaking change P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules

Comments

@hvadehra
Copy link
Member

The type returned by the source_jars field of JavaInfo.java_outputs is being changed from a list to a Depset. This is required to efficiently de-duplicate java_output provider instances in Starlark, since having a list field makes a provider mutable/non-hashable. Not de-duplicating would run into #17170

Migration

If there is a need to support old and new Bazel versions, one can update usages from:

source_jars = java_output.source_jars

to

source_jars = java_output.source_jars
if hasattr(source_jars, "to_list"):
    source_jars = source_jars.to_list()

Alternatively, for a more ergonomic solution, the appropriate check could be added to https://github.com/bazel-contrib/bazel_features

To temporarily preserve the old behavior, one can use the build flag --incompatible_depset_for_java_output_source_jars=false. Note this flag will become a no-op after the next Bazel LTS release (7.0).

copybara-service bot pushed a commit that referenced this issue Jul 19, 2023
#18966

PiperOrigin-RevId: 549238765
Change-Id: Ia2e1f92d23cb3800c2eb9d24a53e79c6c07f9b4b
@sgowroji sgowroji added team-Rules-Java Issues for Java rules incompatible-change Incompatible/breaking change labels Jul 26, 2023
@hvadehra hvadehra added the P2 We'll consider working on this in future. (Assignee optional) label Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules
Projects
None yet
Development

No branches or pull requests

2 participants