KEMBAR78
Implement different scope behavior for generated pom files by vinnybod · Pull Request #1336 · bazel-contrib/rules_jvm_external · GitHub
Skip to content

Conversation

@vinnybod
Copy link
Contributor

@vinnybod vinnybod commented Feb 26, 2025

Background: #1335

TL;DR - #1113 and #1291 regressed in 6.7

The scopes seem counter-intuitive, but "scope" in Maven and Bazel are different, and I think this is the right path forward.
Bazel -
deps are available at compile time and runtime, and are not leaked to dependents
runtime_deps are available at runtime, but not compile time, and are not leaked to dependents
exports leaked to dependents as compile and runtime dependencies
Maven -
compile means the dependency is available at compile time and runtime, and is leaked to dependents
runtime means the dependency is available at runtime, but not compile time. To promote good build hygiene,
this should be the default scope for the generated pom.xml because it means that we don't
leak our dependencies to dependents.

So putting all this together, this is the mapping:
Bazel deps -> Maven runtime
Bazel runtime_deps -> Maven runtime
Bazel exports -> Maven compile

@vinnybod
Copy link
Contributor Author

Keeping as a WIP to wait for discussion and to give some more time for me to test against our internal repos.

@fmeum
Copy link
Member

fmeum commented Feb 27, 2025

Can't we just replace the compile_deps with export_deps? I don't think the former are used for anything else, I introduced them in my PR.

@vinnybod
Copy link
Contributor Author

Yes, that makes sense. I'll make that change.
I am also seeing some issues with javadoc generation in 6.7 in our internal repos, so I am looking into whether that is related to these changes.

@vinnybod
Copy link
Contributor Author

vinnybod commented Feb 28, 2025

Unfortunately it looks like #1291 has also regressed in 6.7
I'll be sure to include tests next time 😅

"example:leaf:1.0.0",
"example:runtime_dep_and_dep_leaf:1.0.0",
], sorted(tut[MavenInfo].maven_compile_deps.to_list()))
], sorted(tut[MavenInfo].maven_export_deps.to_list()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if these tests are still needed, or we could rename it to export_scope

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it, but rename and adapt it to the new semantics.


# the apps-docs target previously failed with this setup.
# now it succeeds.
# todo: how to wrap this in a test target?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use some guidance on this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add an alias to it, that will build it by default.

@vinnybod vinnybod changed the title [WIP] implement different scope behavior for exported pom files Implement different scope behavior for exported pom files Mar 3, 2025
@vinnybod vinnybod changed the title Implement different scope behavior for exported pom files Implement different scope behavior for generated pom files Mar 3, 2025
@vinnybod vinnybod marked this pull request as ready for review March 3, 2025 19:51
@vinnybod vinnybod requested review from cheister, jin and shs96c as code owners March 3, 2025 19:51
Copy link
Collaborator

@shs96c shs96c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @vinnybod, I'll wait until you close the comments from @fmeum before merging, but thank you for adding the tests!

unpacked = _unpack_coordinates(dep)

new_scope = "compile" if dep in versioned_compile_dep_coordinates_set else "runtime"
# This seems counter-intuitive, but "scope" in Maven and Bazel are different.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this comment. It's really useful.

@vinnybod vinnybod requested review from fmeum and shs96c March 4, 2025 19:32
@vinnybod
Copy link
Contributor Author

vinnybod commented Mar 5, 2025

@shs96c just fyi this is ready to go

@shs96c shs96c merged commit 3c3fa50 into bazel-contrib:master Mar 6, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants