-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
[jvm] Split thirdparty/firstparty packages need finer-grained thirdparty definitions #13661
Comments
Having given it a tiny amount of thought, I suspect we're not going to want the exclusions to be defined on I can see in a large-ish repo where a given I suspect it's going to be easier for maintenance to provide overrides at a source file level. We can probably provide this by inference in most cases (certainly after source file analysis). Perhaps My guess is that it's going to be easy enough for us to infer that a given first-party source provides a given type, and if a first-party source provides the type, then that should override a third-party package, unless a dependency is explicitly provided. |
Agreed in general. But a bit more color: the cases I encountered were not cases of actual collisions between symbols: rather, overlapping packages, with some symbols defined via thirdparty, and some locally. Given that, I think that I lean toward "more accurate" thirdparty definitions being preferable. I think that if there had been actual collisions between symbols, explicitly declaring which dependency you wanted would be reasonable... or that the proposals on #13621 would allow marking one target as only visible to a particular resolve.
I don't think that putting this metadata on the source file helps to resolve that though... you'll still have affected all consumers by adding "provides". So in that regard, this seems like a choice between excluding in one place on the
Maybe... but it would be nice for that facility to fit generically with how we solve #13621. I think that the challenge I see with "provides" forcing something to win inference in all cases is that it doesn't allow for three different resolves having different sources of a package without each declaring them. |
I'm trying to feel out what a "more accurate" definition looks like -- in your |
That's correct: the class is not defined in the thirdparty artifact: only locally. The thirdparty artifact otherwise defines the vast majority of the package.
In this case, I view it as making the |
@stuhood Sorry, I musn't have been clear here. Is the class always going to be called Basically, my concern is that defining exclusions at the |
Having let this stew for a bit longer:
I personally think option ii makes the most sense, as it lines up with what you're actually doing: defining a type that should be provided instead of a given JAR. i might work, but I'm not totally sure what the tiebreaking rules should be. |
After some discussion with @tdyas, we're going down the route of adding a This follows the principle of keeping the configuration for a piece of code as close as possible to the code itself. If you define a type called For larger repos, defining these overrides at the The "exclusion" approach may still be something we implement later on, but this is more likely to be useful when defining partially overlapping |
Agreed. Will add that, if there are multiple "DefinedLocally" implementations that conflict, then that condition will be detected when Pants builds the trie. I also recommend calling the field |
Adds a new field to `java_source`(`s`) and `scala_source`(`s`) targets that allow them to strongly declare that they provide a specific JVM type. This excludes these types from being provided by third-party dep inference. This allows first-party sources to provide types that amend a third-party package. Closes #13661
The chosen implementation makes sense to me. If we were to store all this information on |
It's already supposed to be an exhaustive allowlist because it has wildcards... the proposal was to add excludes to handle cases where you know that something doesn't exist remotely or should be ignored. I think that we ended up with a good solution for the latter case, but the former case is a bit more tenuous. |
It is somewhat common (two repos so far) for a firstparty package to overlap a thirdparty package (usually for a handful of classes). But having any overlap at all disables inference for the symbol, which can force adding explicit deps to lots of BUILD files.
It's possible that to resolve this we should support finer-grained package (symbol?) definitions for thirdparty packages. One option which would be sufficient for the cases I've encountered so far would be to allow for a
!
syntax that skips matching for particular symbols. A thirdparty package definition could then do something like:The text was updated successfully, but these errors were encountered: