Skip to content
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 note about sbtPluginPublishLegacyMavenStyle #1164

Merged
merged 3 commits into from
Feb 17, 2024

Conversation

ghostbuster91
Copy link
Contributor

Relates to sbt/sbt#3410

@xuwei-k xuwei-k requested a review from eed3si9n November 1, 2023 11:57
Sbt plugins can be published as any other projects.

However, there is one caveat if you attempt to publish your plugin to a repository that follows the Maven scheme.
For many years, Sbt plugins have utilized an artifact layout that is incompatible with Maven-based repositories, and rectifying this in a fully compatible manner has proven to be quite challenging.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For many years, Sbt plugins have utilized an artifact layout that is incompatible with Maven-based repositories, and rectifying this in a fully compatible manner has proven to be quite challenging.
For many years, sbt plugins have utilized an artifact layout that is incompatible with Maven-based repositories, and rectifying this in a fully compatible manner has proven to be quite challenging.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this sentence is simultaneously too much detail for someone who might be interested in creating a new plugin, and not enough details to accurate capture the problem with pre-1.9 publishing. I don't know if it's clear what was "incompatible" with what, for instance. Maven Central has allowed sbt to publish, and sbt versions going back for many years sbt using either Ivy or Coursier was able to resolve plugins out of Maven Central, so it was compatible in that sense.

The problem with pre-1.9 sbt was that it published in a compatible, but intentionally invalid URL such as https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly_2.12_1.0/2.1.4/sbt-assembly-2.1.4.pom because the artifactId of the module is called sbt-assembly:

<artifactId>sbt-assembly</artifactId>

This was a workaround to preserve the name from sbt as artifactId, while allowing Apache Ivy to find the _2.12_1.0 variant of sbt-assembly from a Maven repository. In an Ivy-layout repository, this concept is expressed as extra attributes, and therefore sbt team has initially recommended hosting sbt plugins on Ivy repository on Artifactory or Bintray. Preserving the name of module allows sbt to round-trip the POM back to our idea of modules, but also it has allowed external services such as https://search.maven.org/search?q=sbt-assembly to treat sbt-assembly as "sbt-assembly", not "sbt-assembly_2.12_1.0" etc.

This invalidity have been ok, apart from the fact that Artifactory has a checkbox called "Suppress POM Consistency Checks", and tried to enforce consistency of the URL layout. Post-1.9 sbt will double-publish to https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly_2.12_1.0/2.1.4/sbt-assembly_2.12_1.0-2.1.4.pom so the URL as well as the artifactId are now valid:

<artifactId>sbt-assembly_2.12_1.0</artifactId>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to drop this sentence as it indeed wasn't bringing much value.

Comment on lines +524 to +528
Notice that you won't be able to consume this plugin with sbt older than 1.9, as it can only resolve the legacy Maven style (or you need to use the trick described in [sbt-vspp](https://github.com/esbeetee/sbt-vspp)).
3. If you use sbt < 1.9.x

You can use https://github.com/esbeetee/sbt-vspp/
5. If you cannot use sbt 1.9.x and you cannot/don't want to use sbt-vspp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The official doc should be written based on the narrative that you should just use the latest stable version of sbt, since if anyone opening a GitHub issue would be told to do so anyway.

Copy link
Contributor Author

@ghostbuster91 ghostbuster91 Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked the first option as recommended, I agree that people should use the latest versions in general, but as we all know well it is simpler said than done. Sometimes there are things that temporarily prevent migration to more recent versions.

Is the current form ok?

@eed3si9n
Copy link
Member

eed3si9n commented Nov 1, 2023

Thanks for the contribution. This would be a useful information to note.

@ghostbuster91
Copy link
Contributor Author

Thanks for the contribution. This would be a useful information to note.

Thanks for the feedback, I think I addressed most of it and sorry for the long delay.

@ghostbuster91
Copy link
Contributor Author

@eed3si9n @xuwei-k hi guys, just a friendly reminder about this one. It's been reviewed and approved, could we please have it merged at your earliest convenience? Thank you!

@eed3si9n eed3si9n merged commit d3f59ad into sbt:develop Feb 17, 2024
2 checks passed
@eed3si9n
Copy link
Member

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants