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

Replace uses of JavaInfo.transitive_export with custom label collection. #557

Merged
merged 1 commit into from
May 12, 2021

Conversation

comius
Copy link
Contributor

@comius comius commented May 10, 2021

In order to simplify JavaInfo provider, we're removing transitive_exports from it (and the native TransitiveExportsProvider).

rules_jvm_external is the only downstream project, that this change breaks.

This PR works with both older and newer versions of Bazel.

Collecting exported labels in an aspect is a better option, because it work also over other Java-like targets (Kotlin, Android) which have JavaInfo provider. transitive_exports also creates problems when defining JavaInfo() and java_common.compile API (because Labels would need to be passed in).

Issue: bazelbuild/bazel#13457

Design document: https://docs.google.com/document/d/10isTEK5W9iCPp4BIyGBrLY5iti3Waaam6EeGVSjq3r8/edit#bookmark=id.34gjanvu5611

@google-cla google-cla bot added the cla: yes label May 10, 2021
@comius comius marked this pull request as ready for review May 10, 2021 16:46
@jin
Copy link
Collaborator

jin commented May 12, 2021

cc @shs96c

Merging this to fix downstream breakage.

Thanks @comius!

@jin jin merged commit 9e8b3e4 into bazel-contrib:master May 12, 2021
illicitonion added a commit to illicitonion/rules_jvm_external that referenced this pull request May 24, 2021
bazel-contrib#557 replaced using
`JavaInfo.transitive_exports` by instead using
`HasMavenDeps.transitive_exports` but it changed how this was computed.

The JavaInfo traversal code:
https://github.com/bazelbuild/bazel/blob/5a647bb234ba9817f51fdb2b4b5973a0602f51a4/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java#L341-L357
only follows the `exports` attribute, and merges together each of the
transitive exports it finds that way.

The replacement starlark code was traversing each of `deps`, `exports`,
and `runtime_deps`, looking for anything which may have been exported
_to_ those targets, which exports significantly more targets.

This adds a unit test to prevent future regressions.
shs96c pushed a commit that referenced this pull request Jul 7, 2021
#557 replaced using
`JavaInfo.transitive_exports` by instead using
`HasMavenDeps.transitive_exports` but it changed how this was computed.

The JavaInfo traversal code:
https://github.com/bazelbuild/bazel/blob/5a647bb234ba9817f51fdb2b4b5973a0602f51a4/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java#L341-L357
only follows the `exports` attribute, and merges together each of the
transitive exports it finds that way.

The replacement starlark code was traversing each of `deps`, `exports`,
and `runtime_deps`, looking for anything which may have been exported
_to_ those targets, which exports significantly more targets.

This adds a unit test to prevent future regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants