-
-
Notifications
You must be signed in to change notification settings - Fork 274
Implement different scope behavior for generated pom files #1336
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
Implement different scope behavior for generated pom files #1336
Conversation
|
Keeping as a WIP to wait for discussion and to give some more time for me to test against our internal repos. |
|
Can't we just replace the |
|
Yes, that makes sense. I'll make that change. |
|
Unfortunately it looks like #1291 has also regressed in 6.7 |
| "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())) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
tests/unit/javadocs/BUILD
Outdated
|
|
||
| # the apps-docs target previously failed with this setup. | ||
| # now it succeeds. | ||
| # todo: how to wrap this in a test target? |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
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.
|
@shs96c just fyi this is ready to go |
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 -
depsare available at compile time and runtime, and are not leaked to dependentsruntime_depsare available at runtime, but not compile time, and are not leaked to dependentsexportsleaked to dependents as compile and runtime dependenciesMaven -
compilemeans the dependency is available at compile time and runtime, and is leaked to dependentsruntimemeans 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-> MavenruntimeBazel
runtime_deps-> MavenruntimeBazel
exports-> Mavencompile