An sbt plugin for publishing/consuming packages to/from AWS CodeArtifact.
First, you will need a CodeArtifact repository. Then, add the following to your sbt
addSbtPlugin("io.github.richarddowsett" % "sbt-codeartifact" % version)
Note that when specifying
sbt-codeartifact settings in
project/*.scala files (as opposed to in the root
build.sbt), you will need to add the following import:
CodeArtifact provides instructions on how to connect to your repository. Click "View Connection Instructions", then choose "gradle", then copy the
Here's an example
build.sbt file that assumes a CodeArtifact repository named "private" in the "com.example" domain has been created:
organization := "com.example" name := "library" version := "0.1.0" scalaVersion := "2.13.4" codeArtifactUrl := "https://com-example-1234567890.d.codeartifact.us-west-2.amazonaws.com/maven/private"
Then, to publish, run:
A resolver for your repository is added based on the
codeArtifactUrl key. You can add more repositories manually like so:
val codeArtifactUrlBase = "https://com-example-1234567890.d.codeartifact.us-west-2.amazonaws.com/maven/" codeArtifactUrl := codeArtifactUrlBase + "release" codeArtifactResolvers := List("foo", "bar", "baz").map(repo => codeArtifactUrlBase + repo)
sbt:library> show resolvers [info] * com-example/release: https://com-example-1234567890.d.codeartifact.us-west-2.amazonaws.com/maven/release [info] * com-example/foo: https://com-example-1234567890.d.codeartifact.us-west-2.amazonaws.com/maven/foo [info] * com-example/bar: https://com-example-1234567890.d.codeartifact.us-west-2.amazonaws.com/maven/bar [info] * com-example/baz: https://com-example-1234567890.d.codeartifact.us-west-2.amazonaws.com/maven/baz
Your CodeArtifact Authentication Token is fetched dynamically using the AWS Java SDK. Credentials are resolved using the DefaultCredentialsProvider.
If you would like to provide the token statically (for example, if your AWS creds are unavailable), then you can provide the token as an environment variable:
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain domain-name --domain-owner domain-owner-id --query authorizationToken --output text --profile profile-name`
If you would like to provide
~/.sbt/credentials, you can do so with the following format
realm=<realm> host=<host> user=<user> password=<password>
import ReleaseTransformations._ releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, inquireVersions, runClean, runTest, setReleaseVersion, commitReleaseVersion, tagRelease, // This is the only step that varies. releaseStepCommandAndRemaining("codeArtifactPublish"), setNextVersion, commitNextVersion, pushChanges )