Skip to content

Commit

Permalink
Merge pull request #28 from ckipp01/sonatypeHost
Browse files Browse the repository at this point in the history
feat: add in a sonatypeHost setting and Pom checks
  • Loading branch information
ckipp01 authored Nov 2, 2022
2 parents 3333c1b + e4a9b16 commit c1cf0b5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ this [here][sonatype-setup]. If you don't have a domain name you can use

**NOTE**: Keep in mind that as of February 2021 newly created accounts are tied
to https://s01.oss.sonatype.org/ whereas older accounts will be tied to
https://oss.sonatype.org/. This matters when logging in, setting your resolvers,
and setting your `sonatypeUri` and `sonatypeSnapshotUri`.
https://oss.sonatype.org/. This matters when logging in. You'll also want to
make sure you set `sonatypeHost` to `SonatypeHost.s01` in this scenario.

### Installing the Plugin

Expand Down Expand Up @@ -61,12 +61,14 @@ if you were extending `PublishModule`.
you'll also want to ensure you add the following:

```diff
+ override def sonatypeUri = "https://s01.oss.sonatype.org/service/local"
+ override def sonatypeSnapshotUri =
+ "https://s01.oss.sonatype.org/content/repositories/snapshots"
+ import io.kipp.mill.ci.release.SonatypeHost
...
+ override def sonatypeHost = SonatypeHost.s01
```

If you have an older account, then there is no need to change the default.
This will then set the correct `sonatypeUri` and `sonatypeSnapshotUri` for you.
If you have an older account, then there is no need to change the default or use
`sonatypeHost` at all.

### GPG

Expand Down
1 change: 0 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ object plugin
override def compileIvyDeps = super.compileIvyDeps() ++ Agg(
ivy"com.lihaoyi::mill-scalalib:${millVersion}"
)

override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"de.tototec::de.tobiasroeser.mill.vcs.version_mill0.10::0.3.0"
)
Expand Down
39 changes: 36 additions & 3 deletions plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ trait CiReleaseModule extends PublishModule {
override def publishVersion: T[String] = T {
VcsVersion.vcsState().format(untaggedSuffix = "-SNAPSHOT")
}

/** Helper available to users be able to more easily use the new s01 and
* future hosts for sonatype by just setting this.
*/
def sonatypeHost: Option[SonatypeHost] = None

override def sonatypeUri: String = sonatypeHost match {
case Some(SonatypeHost.Legacy) => "https://oss.sonatype.org/service/local"
case Some(SonatypeHost.s01) => "https://s01.oss.sonatype.org/service/local"
case None => super.sonatypeUri
}

override def sonatypeSnapshotUri: String = sonatypeHost match {
case Some(SonatypeHost.Legacy) =>
"https://oss.sonatype.org/content/repositories/snapshots"
case Some(SonatypeHost.s01) =>
"https://s01.oss.sonatype.org/content/repositories/snapshots"
case None => super.sonatypeSnapshotUri
}
}

object ReleaseModule extends ExternalModule {
Expand All @@ -36,12 +55,18 @@ object ReleaseModule extends ExternalModule {
setupGpg()()
val env = envTask()

val modules = releaseModules(ev).map { m =>
val modules = releaseModules(ev)

val uris = modules.map { m =>
(m.sonatypeUri, m.sonatypeSnapshotUri)
}

val sonatypeUris = modules.map(_._1).toSet
val sonatypeSnapshotUris = modules.map(_._2).toSet
val sonatypeUris = uris.map(_._1).toSet
val sonatypeSnapshotUris = uris.map(_._2).toSet

val allPomSettings = modules.map { m =>
Evaluator.evalOrThrow(ev)(m.pomSettings)
}

def mustBeUniqueMsg(value: String, values: Set[String]): String = {
s"""It looks like you have multiple different values set for ${value}
Expand All @@ -57,6 +82,14 @@ object ReleaseModule extends ExternalModule {
Result.Failure[Unit](
mustBeUniqueMsg("sonatypeSnapshotUri", sonatypeSnapshotUris)
)
} else if (allPomSettings.flatMap(_.licenses).isEmpty) {
Result.Failure[Unit](
"You must have a license set in your PomSettings or Sonatype will silently fail."
)
} else if (allPomSettings.flatMap(_.developers).isEmpty) {
Result.Failure[Unit](
"You must have a at least one developer set in your PomSettings or Sonatype will silently fail."
)
} else {
// Not ideal here to call head but we just checked up above and already failed
// if they aren't size 1.
Expand Down
7 changes: 7 additions & 0 deletions plugin/src/io/kipp/mill/ci/release/SonatypeHost.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.kipp.mill.ci.release

sealed trait SonatypeHost
object SonatypeHost {
case object Legacy extends SonatypeHost
case object s01 extends SonatypeHost
}

0 comments on commit c1cf0b5

Please sign in to comment.