laughedelic / sbt-publish-more   0.1.0


:outbox_tray: Publish artifacts to more than one repository

Scala versions: 2.12
sbt plugins: 1.0


This SBT plugin allows you to publish artifacts to more than one repository.

It's inspired by the sbt-multi-publish plugin, which is unfortunately completely outdated and uses another, more limited approach.

It may be useful to be able to publish your project to several repositories at once, for example:

  • to the community Bintray repository
  • to your company's private server
  • to some local/proxy repository

But the publishTo setting accepts only one resolver. This is where this plugin comes to the rescue!


Add plugin to your project/plugins.sbt:

addSbtPlugin("laughedelic" % "sbt-publish-more" % "<version>")

(see the latest release version on the badge above)

Requirements: This plugins requires sbt 1.x

NOTE: This plugin is in active development, so things are likely to change. Check release notes and usage section in the Readme every time you update to a new version.


  1. Set publishResolvers := Seq(...)
  2. Call publishAll task

Multiple publish resolvers

If you want to publish to several repositories you just need to set the publishResolvers setting. For the example from above it will look like this:

publishResolvers := Seq(,
  Resolver.url("my-company-repo", url("")),
  Resolver.file("my-local-repo", file("path/to/my/local/maven-repo"))

See sbt documentation for more types of resolvers.

Setting publishResolvers will also set publishTo to the first resolver in the list.

Now you can call publishAll task to publish to every resolver in the publishResolvers list. Note that if you want it to be the default behavior, you should change the standard publish task:

publish := publishAll.value

Different publish configurations (experimental)

By default it will publish to each repository with the same default publish configuration (that is stored in the publishConfiguration setting), as if you would call normal publish task several times while manually changing publishTo setting.

But you may want to publish to different repositories with different configurations. For example, maven-style vs. ivy-style patterns, or different sets of artifacts. So this plugin adds a setting publishCustomConfigs, which stores a mapping of Resolvers to their corresponding PublishConfigurations.

Say you want to publish to one repository maven-style (default) and to the other ivy-style. First, you should define your publish resolvers (in build.sbt):

lazy val repo1 = Resolver.file("repo1",  file("example/repo1"))
lazy val repo2 = Resolver.file("repo2",  file("example/repo2"))(Resolver.ivyStylePatterns)

publishResolvers := Seq(repo1, repo2)

It's better to define values for resolvers, because we will need to refer to them in the next step. The second one needs explicit ivy-style patterns, because the default is maven-style.

Then we add a custom configuration for repo2:

publishCustomConfigs ++= Map(
  repo2 -> publishConfiguration.value.withPublishMavenStyle(false)

This will make it generate the ivy.xml artifact. Now when you call publishAll you will get your maven-style artifacts in repo1 and ivy-style artifacts (with ivy.xml) in repo2.

You can change any other PublishConfiguration parameters this way and do it for every particular repository you want to publish to.