-
-
Notifications
You must be signed in to change notification settings - Fork 271
Add an implementation_deps
argument to java_export
#1113
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
Add an implementation_deps
argument to java_export
#1113
Conversation
* add bazel equivalent of gradle's 'implementation' scope * update get_implementation_coordinates * Update private/rules/maven_utils.bzl * Update private/rules/pom_file.bzl
Thank you for the PR. I like the idea, but Bazel already allows us to model runtime deps using the |
Are you suggesting that this would still require changes, just not a new field? Or are you suggesting that I should just be able to pass the deps in as I did try duplicating all my |
I’m saying we don’t need the new field because the Java rules already allow us to express the concept of a runtime dependency. We need to change how we generate the pom file to reflect this. |
We don’t currently draw a distinction between the two kinds of deps in the |
I see, thanks! I'll come back to this on Monday and try to do it that way. |
@shs96c Maybe you could give me a bit of guidance on where the changes are needed? I've been looking through My first thought was just to get the scope into the |
In theory, this is relatively straight-forward. In practice, it might well be fiddly. The way that we figure out which Maven dependencies belong to a
This means that once we reach the target we're dealing with, the
We need to take the difference of the sets of dependencies, since one It sounds like a lot, but I think most of the infrastructure for this is already present, since we needed to write some of it to support the |
This update adds a new field for tracking runtime_deps in the This method didn't require using a diff of any sets, but maybe I am missing the use case. Working on this does have me thinking of an alternative approach, though it may be considered a breaking change for It seems like we could take a page out of Gradle's methodology for generated pom files. Using compile scope on the generated pom leaks the dependencies to the consuming maven project, while runtime doesn't. |
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 making these changes. We can add a test case in a follow-up PR, but some manual checks show that this is working as I would expect it. This is a really nice feature, so thank you! LGTM.
We are migrating a Gradle project to Bazel and can't break compatibility with other Java repos that import the Maven artifacts.
Gradle has a concept of
implementation
dependencies. These dependencies are available at compile time when building the library, but are given aruntime
scope in the generatedpom.xml
file for consumers of the library to avoid leaking the dependency to the consumers at compile time.This adds a list to
java_export
calledimplementation_deps
. The targets passed here and indeps
will be given aruntime
scope on the generatedpom.xml
, but will still be available at compile time to the java_library like normaldeps
. It only impacts pom generation.This is different than
runtime_deps
because we still need the dependencies at compile time.