Giter Site home page Giter Site logo

sbt-s3-resolver's Introduction

Sbt S3 resolver

This is an sbt plugin, which helps to resolve dependencies from and publish to Amazon S3 buckets (private or public).

Features

This plugin can publish artifacts in maven or ivy style, but it can resolve only ivy artifacts:

Ivy artifacts publish resolve Maven artifacts publish resolve
public public *
private private

Usage

Plugin sbt dependency

In project/plugins.sbt:

resolvers += "Era7 maven releases" at "https://s3-eu-west-1.amazonaws.com/releases.era7.com"

addSbtPlugin("ohnosequences" % "sbt-s3-resolver" % "<version>")

(see the latest version in the releases list)

Note that since v0.11.0 this plugin is compiled and published only for scala-2.10/sbt-0.13 or higher. If you want it for sbt-0.12, use version v0.10.1.

Setting keys

Key Type Default
awsProfile String "default"
s3credentials AWSCredentialsProvider see below
s3region Region EU_Ireland
s3overwrite Boolean same as isSnapshot key
s3acl S3ACL PublicRead
s3resolver (String, s3) => S3Resolver is set using all above

Where

type Region = com.amazonaws.services.s3.model.Region
type AWSCredentialsProvider = com.amazonaws.auth.AWSCredentialsProvider
type S3ACL = com.amazonaws.services.s3.model.CannedAccessControlList

These defaults are added to your project automatically. So you can just tune the settings keys in build.sbt.

You can use s3resolver setting key that takes a name and an S3 bucket url and returns S3Resolver which is implicitly converted to sbt.Resolver.

Publishing

Normal practice is to use different (snapshots and releases) repositories depending on the version. For example, here is such publishing resolver with ivy-style patterns:

publishMavenStyle := false

publishTo := {
  val prefix = if (isSnapshot.value) "snapshots" else "releases"
  Some(s3resolver.value("My "+prefix+" S3 bucket", s3(prefix+".cool.bucket.com")) withIvyPatterns)
}

You can also switch repository for public and private artifacts — you just set the url of your bucket depending on something. Here s3 constructor takes the name of your S3 bucket (don't worry about s3:// prefix).

Resolving

You can add a sequence of S3 resolvers just like this:

resolvers ++= Seq[Resolver](
  s3resolver.value("Releases resolver", s3("releases.bucket.com")),
  s3resolver.value("Snapshots resolver", s3("snapshots.bucket.com"))
)

Note, that you have to write Seq[Resolver] explicitly, so that S3Resolvers will be converted to sbt.Resolver before appending.

Public Maven artifacts

If your maven artifacts are public, you can resolve them using usual sbt resolvers just transforming your s3://my.bucket.com to

"My S3 bucket" at "https://s3-<region>.amazonaws.com/my.bucket.com"

i.e. without using this plugin. Or if you're using it anyway, you can write:

"My S3 bucket" at s3("my.bucket.com").toHttps(s3region.value)

Credentials

s3credentials key has the AWSCredentialsProvider type from AWS Java SDK. Different kinds of providers look for credentials in different places, plus they can be chained by the | ("or") operator (added in this plugin for convenience).

The default credentials chain in this plugin is

awsProfile := "default"

s3credentials :=
  new ProfileCredentialsProvider(awsProfile.value) |
  new InstanceProfileCredentialsProvider()

You can find other types of credentials providers in the AWS Java SDK docs

If you have different profiles in your ~/.aws/credentials file, you can choose the one you need by setting

awsProfile := "bob"

Or if you need a completely different credentials providers chain, you can change it, for example, like this:

s3credentials :=
  file(System.getProperty("user.home")) / ".sbt" / ".s3credentials" |
  new EnvironmentVariableCredentialsProvider() |
  new SystemPropertiesCredentialsProvider()

You can check which credentials are loaded with the showS3Credentials task:

sbt showS3Credentials

Patterns

You can set patterns using .withPatterns(...) method of S3Resolver. Default are maven-style patterns (just as in sbt), but you can change it with the convenience method .withIvyPatterns.

Contacts

This project is maintained by @laughedelic. Join the chat-room if you want to ask or discuss something
![Gitter](https://badges.gitter.im/Join Chat.svg)

sbt-s3-resolver's People

Contributors

laughedelic avatar eparejatobes avatar orrsella avatar tminglei avatar

Watchers

James Cloos avatar

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.