xerial / sbt-sonatype

A sbt plugin for publishing Scala/Java projects to the Maven central.
Apache License 2.0
335 stars 65 forks source link

feature: Give helpful advice when profile missing on host #461

Closed rtyley closed 10 months ago

rtyley commented 11 months ago

This updates the error message given when a profile is not found on a host (note Sonatype currently has 2 OSS hosts - oss.sonatype.org & s01.oss.sonatype.org - and any profile will only exist on one of the hosts).

image

(example here)

There can be two possible causes when a profile is not found on a host:

  1. The profile name is misspelt/incorrect (eg 'com.gnu' or 'john.smith' instead of 'com.gu')
  2. The profile is actually on the other Sonatype OSS host

The original error message really only indicated the possibility of the 1st problem, but the 2nd issue is increasingly likely - since February 2021 new profiles have only been registered on the new host s01.oss.sonatype.org, and sbt-sonatype defaults to using the older host, oss.sonatype.org.

The new error message aims to make the user aware of the 2 possible causes of the 'missing profile' problem, and offer advice on how the 2nd problem could be corrected.

Before:

Profile com.gu is not found. Check your sonatypeProfileName setting in build.sbt

After:

Profile com.gu is not found on oss.sonatype.org. In your sbt settings, check your sonatypeProfileName and sonatypeCredentialHost (try s01.oss.sonatype.org?)"

Sonatype host is determined by-profile (not by-user)

Note that in the past, there's been a bit of confusion (ok, I've been a bit confused!) about whether hosts are assigned on a by-user or by-profile basis (many users can be granted access by Sonatype to upload to one profile, eg we at the Guardian have that for our com.gu profile). It's definitely per-profile though - so sonatypeProfileName dictates which sonatypeCredentialHost you want to be using.

As a user (eg, for me, with my Sonatype user account 'roberto') working on a variety of projects with different profiles (eg, for me, working on projects under com.gu, com.madgag & org.scanamo) when I'm performing a release I'll be uploading to either oss.sonatype.org, or s01.oss.sonatype.org, depending on which profile/groupId that particular project lives under.

xerial commented 10 months ago

i just noticed this PR. Will take a look

rtyley commented 10 months ago

i just noticed this PR. Will take a look

Thanks @xerial! How does it look to you? I'm happy to make changes if required?

xerial commented 10 months ago

Merged with some fixes for code cosmetics

rtyley commented 10 months ago

Thank you!