[Question] - Retrieving sbt plugin versions from hosted Sonatype Nexus
See original GitHub issueAt my work we use Scala Steward to update all of our internal dependencies. We use a hosted Sonatype Nexus to both have a mirror of Maven Central and also to have our own internal releases Maven repo. From looking through the Scala Steward code it seems that it relies on Coursier to retrieve the list of versions available for the artifact.
If I understand it right, this is done for artifacts that have a maven-metadata.xml
file, but as you know, sbt plugins that are published Maven style don’t have one. Which again, to my understanding because of this, Coursier then relies on the directory listing? This is how it seems to work for our maven-central mirror with the sbt-scalafmt
plugin. By looking at it with a path like this, I can see an html directory listing of all versions:
https://nexus-redacted.com/repository/maven-public/org/scalameta/sbt-scalafmt_2.12_1.0
Scala Steward (Coursier) is able to correctly gather the versions (again I assume from this and sounds like that from this thread in Steward). However, I’m finding a lot of contradictory information about whether or not this is available on different versions of Nexus3. Plus those that manage our Nexus is saying there is no option to turn this on.
- Community post saying that it exists but is at a different path now <-- This seems to be the case
- Sonatype ticket to create this feature
- Another ticket for the raw tree view
- Announcement saying it’s now supported in 3.7
- SO post saying it’s in a different location now
From what I can tell, for our own internal nexus where I’d expect the directory listing to be like the sbt-scalafmt
example above, it just 404’s.
https://nexus-redacted.com/repository/redacted-releases/redacted/redacted/sbt-redacted_2.12_1.0
There is an html index of sorts at this url:
https://nexus-redacted.com/service/rest/repository/browse/redacted-releases/redacted/redacted/sbt-redacted_2.12_1.0/
However, looking through the code here, I don’t believe that will work: https://github.com/coursier/coursier/blob/59bf7739079f6b906ecb77435c8afce2d3658f2c/modules/core/shared/src/main/scala/coursier/maven/MavenRepository.scala#L208-L252
And when Scala Steward attempts to get the available versions of the plugin, it gets none and therefore doesn’t send in prs for our internal sbt plugins. Which sort of leads me to believe that because of the lack of directory listing there, Coursier isn’t getting the versions? Do you know if it’s possible for Coursier to get the versions of an sbt plugin without the directory listing, or does that have to be there? Or could there be another check possible to capture this alternative html view the same way the other is captured?
EDIT: For the time being we just add in a custom release step to create / update the maven-metadata.xml
file, but it’d still be great to see if what I mentioned above is the case or not.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (7 by maintainers)
Top GitHub Comments
Just to clarify, yes, it does work now with us creating the
maven-metadata.xml
file, but was curious if there was a solution where having that step to manually create one for sbt plugins on self-hosted nexus would no longer be necessary.So this is a pretty hacky solution, but we essentially just included this as a custom release step (if you use sbt-release).
It’s pretty self-explanatory, but it will just check to see if there is a metadata file, and if not create one. If it does fine one, it just updates it. It’s using requests-scala for the calls.