GithubHelp home page GithubHelp logo

laughedelic / sbt-publish-more Goto Github PK

View Code? Open in Web Editor NEW
23.0 4.0 8.0 32 KB

:outbox_tray: Publish artifacts to more than one repository

License: Other

Scala 100.00%
sbt publish-resolvers sbt-plugin scala publishing artifacts

sbt-publish-more's Introduction

sbt-publish-more

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!

Usage

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.

TL;DR

  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(
  publishTo.in(bintray).value,
  Resolver.url("my-company-repo", url("https://company.com/releases/")),
  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.

sbt-publish-more's People

Contributors

laughedelic avatar vshalts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sbt-publish-more's Issues

Signed publishing?

I'm not sure if it's supported but from what I can see it isn't.

Could you add a task like publishAllSigned?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.