-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hi,
When updating to a newer version of smithy-language-server that uses maven-resolver(aether) instead of coursier for dependency resolution (introduced in #113) we noticed a difference in behavior that was not expected.
I am skipping the details of that difference for brevity because it was quite complex. The end result was that the language server was seeing some old version of a dependency in the project's classpath - it was smithy-model version 1.27 instead of version 1.36 (artifacts/versions aren't important, I just use them to make it more concrete)
After closer inspection of the classpath we noticed that smithy-model is being included twice transitively by two different artifacts in two different versions - 1.27.0 and 1.36.0.
Previously, coursier in such cases was always picking the latest version. However, the behavior of maven-resolver is different. If you take a look into MavenRepositorySystemUtils the class that smithy-cli uses to instantiate DefaultRepositorySystemSession you will see that it defines ConflictResolver as follows:
DependencyGraphTransformer transformer = new ConflictResolver(
new NearestVersionSelector(), new JavaScopeSelector(),
new SimpleOptionalitySelector(), new JavaScopeDeriver());where "nearest" means:
Nearest is defined as the declaration that has the least transitive steps away from the project being built.
In our cases the newer version was indeed one step deeper than the older one, but no one was paying attention to how many nesting steps of transitive dependencies there are.
This seems indeed to be the way of how maven works by default as at the time of writing there is no other implementation of VersionSelector besides NearestVersionSelector.
The solution in our case was simply - just add the smithy-model with the correct version as an explicit dependency in smithy-build.json.
Was this change intentional? Would you be interested in providing an option to restore old behavior, so that users have a smoother migration path?