How to publish a library with scala sbt to two maven repositories?

38 Views Asked by At

I am trying to publish a library to two maven repositories using scala sbt. I am trying to do that because we are migrating our infrastructure and for a time we need to have the library in two different maven repos.

I found another similar question, however the answers are very old. Some on them suggest to use a plugin that is not maintained anymore.

What is the best way of doing that?

Thank you!

1

There are 1 best solutions below

0
Diego On

I found this answer and it gave me the idea of creating a custom command, similar to the answer here.

How to change setting inside SBT command?

The only thing I changed was that executing a command should be done in the following way:

  def publishNexus = Command.command("publishNexus") { state =>
  val extracted = Project extract state
  val newState = extracted.appendWithSession(
    Seq(subproject / publishToNexus := true),
    state,
  )
  "publish" :: newState
}