-
Notifications
You must be signed in to change notification settings - Fork 322
Try resolve sbt plugin from valid Maven pattern #2633
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
Conversation
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 the PR!
If we stick with this approach (special-case the support of sbt 1.x plugins) we should thoroughly document the parts of the code that handle that.
modules/core/shared/src/main/scala/coursier/core/Definitions.scala
Outdated
Show resolved
Hide resolved
modules/core/shared/src/main/scala/coursier/maven/MavenRepository.scala
Outdated
Show resolved
Hide resolved
modules/core/shared/src/main/scala/coursier/maven/MavenRepository.scala
Outdated
Show resolved
Hide resolved
As discussed briefly with @julienrf on other channels, I feel a bit reluctant to add more sbt-specific hacks in the resolver. The goal of switching to standard Maven paths for plugins should be to make sbt plugin handling more "standard", not to add more sbt-specific branches in coursier. Isn't possible to handle this externally, outside of the resolver, from sbt or sbt-coursier say? I think something along those lines could work:
A benefit of that approach is that it can basically be handled entirely from sbt. It might feel more hack-ish, but at least the hacks would be restricted to sbt projects. |
Another benefit of the approach I described would be that it would make it easier to sunset support for legacy paths in the future. The legacy path detection before resolution, and the duplicate detection right after, would just have to be removed. |
942d9c9
to
fe2ecf7
Compare
Thanks @alexarchambault for sharing your feedback. I understand your point. It is indeed unfortunate that sbt special handling is leaking into Coursier. However there are a number of related things that this work can solve, among which:
The price to pay, to fix those in sbt 1.x, is:
Why not wait for sbt 2.x to fix that issue? Assuming sbt 2.x is released next year, which is uncertain, then we will have to move the entire plugin ecosystem to it, which will take some time, probably more than a year. We will have to deal with cross-building of plugins, in Scala 2.12 for sbt 1.x, and Scala 3 for sbt 2.x, which makes things harder and slower. Not that we don't know how to do it, but it will take time. And the users will continue using sbt 1.x for a few more months. Here by fixing it in sbt 1.9, the transition to the new valid Maven pattern is fast and very smooth for all users. Plugin authors just need to bump the version of sbt and to release. It's all bi-directional compatible for plugin authors and plugin users. In Coursier itself I think the added complexity is reasonable. It boils down to two main things:
That's about 20 lines of code, including comments. The rest of the changes are mostly 104 lines of tests, 45 lines of added utils in Definitions, among which a lot of comments to make things as clear as possible.
I understand why you want to move the hack closer to sbt but I am afraid this is a lot more complex, and I am doubtful about your solution. Would it be even possible to do things properly:
In contrast, with the proposed implementation of that PR, the hack is minimal and everything is working as expected:
I also think we can remove all the special handling in Coursier after sbt 2.x. That means sbt 1.x would have to live on a legacy version of Coursier but that looks fine to me. |
fe2ecf7
to
0997bed
Compare
I know, these are great points, I don't propose to go against them, quite the opposite! My only concerns are about the implementation: I'd rather have sbt and sbt-coursier (which somehow belongs more to the sbt realm than to the coursier one) handle those concerns, rather than the core of coursier.
Precisely, I think we can achieve this without modifying coursier itself, but by modifying sbt and sbt-coursier. |
Still, there's already a hack for sbt plugins in coursier (to handle the soon-to-be-legacy non-standard paths). My feeling is this hack is here to stay, even though no new plugins will rely on it. As I'd like the coursier CLI to still be able to resolve legacy-paths plugins in the future, like To be more specific, I'd see most changes implemented in sbt-coursier, roughly following those lines:
|
Yeah, but it's an sbt-specific hack. It should just live in sbt-land, not in the core of the resolver.
Resolution returns detailed errors, so that's tractable.
This could also probably be handled in sbt-land, if we put the excluded dependencies in the update report (I don't recall if we do or not…) That said, that would only be a problem during the transition period, and would only affect sbt plugins.
If the plugins are to be published in a standard way, you shouldn't need attributes anymore. Just like Scala libraries or Scala.js are libraries are simply published with suffixes such as |
I am still not quite convinced by your solution because:
May I again say that this PR adds no more than 20 lines of hacks, localized in MavenRepository and PomParser, couting the 7 lines of comments.
I would rather suggest to drop the support of sbt 1.x in Coursier, just after the release of sbt 2.x. That would be soft, as it would still be possible to do:
|
Hi @alexarchambault! "My feeling is this hack is here to stay" -- it seems to me that if there already are SBT specific hacks in the resolver, any solution to move #2633 out of coursier, should bring with it together that old SBT specific-hack as well. Otherwise we have 2 sets of hacks in 2 different places, quadrupling the complexity of the problem. The hack is definitely not here to stay, it is rather to enable a smooth transition between the old world and the new world. The sbt-vspp plugin (for publishing valid artifacts) is already used by at least a dozen SBT plugins, half of which adopted it without prompting. The migration into the new world has already begun - for plugins that have no dependencies on other plugins. Those that have dependencies on other plugins, such as sbt-scalajs, have a more tricky story in terms of dependencies. Once you bump to SBT 2.x, new versions of coursier can rid of this hack immediately, without breaking users of new SBT or old SBT. Regarding Ivy, the Ivy publishing is fine and I'd steer far from touching it, as the issue is purely in the Maven-POM land due to the extra attributes and "inconsistent" file paths/POMs published. |
6f270b3
to
ab45519
Compare
sbt plugins were published to an invalid path with regard to Maven's specifictation. For instance, 'org/example_2.12_1.0/1.0.0/example-1.0.0.pom' is invalid because the file name 'example-1.0.0.pom' does not start with 'example_2.12_1.0', the name of the directory that should correspond to the artifact ID. As of sbt 1.9, we also publish sbt plugins to the valid path: example_2.12_1.0/1.0.0/example_2.12_1.0-1.0.0.pom For backward compatibility, Coursier should try to resolve sbt plugins from the new Maven path, and fallback to the deprecated Maven path.
Remove sbtAttrsStub from MavenRepository Remove extraAttributes handling from PomParser
ab45519
to
9c1f5d5
Compare
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.
@alexarchambault This is ready for review.
As discussed in a meeting, I extracted all the sbt hacks in a new module coursier-sbt-maven-repository
. See comments below for more details.
@@ -49,6 +51,10 @@ object core extends Module { | |||
object jvm extends Cross[CoreJvm](ScalaVersions.all: _*) | |||
object js extends Cross[CoreJs](ScalaVersions.all: _*) | |||
} | |||
object `sbt-maven-repository` extends Module { |
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.
Added new module coursier-sbt-maven-repository
containing SbtMavenRepository
, SbtPom
and SbtPomParser
coursier-cli
depends on this new artifact.
case m: MavenRepository => | ||
case m: MavenRepositoryBase => |
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.
To make sure that both MavenRepository
and SbtMavenRepository
support mirrors.
@@ -842,21 +842,6 @@ object ResolveTests extends TestSuite { | |||
} | |||
} | |||
|
|||
"config handling" - async { |
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.
Moved to SbtPluginResolveTests
in tests
Deps.dataClass | ||
) | ||
} | ||
trait SbtMavenRepositoryJvmBase extends SbtMavenRepository with CsMima |
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.
Here I don't think we need shading, since it only depends on core
which is already shaded.
In particular, emove MavenRepositoryBase, and replace it with MavenRepositoryLike (meant to be used by users) and MavenRepositoryInternal (purely internal, where MavenRepository and SbtMavenRepository shared implems)
modules/core/shared/src/main/scala/coursier/maven/MavenRepositoryLike.scala
Show resolved
Hide resolved
Ok, so merging this! (Going to look at https://github.com/coursier/sbt-coursier/pull/445/files next) Thanks @adpi2! |
Thank you @adpi2 , @alexarchambault , this is really exciting! |
Thanks @alexarchambault for taking care of this while I was away. Getting rid of the |
Since coursier/coursier#2633 handling for resolving sbt plugins from Maven repositories got extracted into `SbtMavenRepository` in the `coursier-sbt-maven-repository` module
This PR is part of sbt/sbt#7096 whose goal is to fix sbt/sbt#3410 in a smooth way. For a full description please read sbt/sbt#7096.
See also coursier/test-metadata#7 for the added test metadata.