Skip to content

Commit 6d4db24

Browse files
committed
Suggest a correct sonatype server in the case of errors
1 parent bcd88fe commit 6d4db24

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,15 +1026,15 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
10261026
Severity.Warning
10271027
)
10281028
val repoParams0: RepoParams = repoParams.withAuth(authOpt0)
1029+
val isLegacySonatype = isSonatype && !repoParams0.repo.releaseRepo.root.contains("s01")
10291030
val hooksDataOpt = Option.when(!dummy) {
10301031
try repoParams0.hooks.beforeUpload(finalFileSet, isSnapshot0).unsafeRun()(ec)
10311032
catch {
10321033
case NonFatal(e)
10331034
if "Failed to get .*oss\\.sonatype\\.org.*/staging/profiles \\(http status: 403,".r.unanchored.matches(
10341035
e.getMessage
10351036
) =>
1036-
logger.exit(new WrongSonatypeServerError(
1037-
repoParams0.repo.releaseRepo.root.contains("s01")))
1037+
logger.exit(new WrongSonatypeServerError(isLegacySonatype))
10381038
case NonFatal(e)
10391039
if "Failed to get .*oss\\.sonatype\\.org.*/staging/profiles \\(http status: 401,".r.unanchored.matches(
10401040
e.getMessage
@@ -1096,7 +1096,8 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
10961096
s"""
10971097
|Uploading files failed!
10981098
|Possible causes:
1099-
|- no rights to push to under this organization or organization name is misspelled
1099+
|- no rights to publish under this organization
1100+
|- organization name is misspelled
11001101
| -> have you registered your organisation yet?
11011102
|""".stripMargin
11021103
)
@@ -1112,7 +1113,9 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
11121113
|Possible causes:
11131114
|- incorrect Sonatype credentials
11141115
|- your Sonatype password or username may contain unsupported characters
1115-
|- incorrect Sonatype server was used (legacy or s01)
1116+
|- incorrect Sonatype server was used, try ${
1117+
if isLegacySonatype then "'central-s01'" else "'central'"
1118+
}
11161119
| -> consult publish subcommand documentation
11171120
|""".stripMargin
11181121
)

modules/cli/src/main/scala/scala/cli/errors/WrongSonatypeServerError.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import scala.build.errors.BuildException
44

55
final class WrongSonatypeServerError(legacyChosen: Boolean)
66
extends BuildException(
7-
s"Wrong Sonatype server, try with ${if legacyChosen then "'central-s01'" else "'central'"}",
7+
s"Wrong Sonatype server, try ${if legacyChosen then "'central-s01'" else "'central'"}"
88
)

0 commit comments

Comments
 (0)