As explained here, one can deploy to Amazon S3 with maven.
How can we do the same with sbt, that is, to publish to S3 with sbt?
As explained here, one can deploy to Amazon S3 with maven.
How can we do the same with sbt, that is, to publish to S3 with sbt?
Here is an SBT Plugin I wrote for publishing to Amazon S3: https://github.com/frugalmechanic/fm-sbt-s3-resolver
It's similar to the already mentioned sbt-s3-resolver but is Apache 2.0 Licensed (instead of AGPL) and is available on Maven Central. It's also a little easier to use and configure.
publishTo := Some("S3" at "s3://s3-us-west-2.amazonaws.com/YOUR_BUCKET/repo")
resolvers += "S3" at "s3://s3-us-west-2.amazonaws.com/YOUR_BUCKET/repo"
Just add this to your project/plugins.sbt file:
addSbtPlugin("com.frugalmechanic" % "fm-sbt-s3-resolver" % "0.19.0")
There are multiple ways to configure the AWS Credentials which are documented on the GitHub Page.
One method is to create an ~/.sbt/.s3credentials that looks like:
accessKey = XXXXXXXXXX
secretKey = XXXXXXXXXX
The credentials file will be automatically picked up by the plugin and you will be able to resolve and publish.
resolvers += "FrugalMechanic Snapshots" at "s3://maven.frugalmechanic.com/snapshots"
Is it still alive ? –
Sprage The question is pretty old, so may be you already found some workaround, but may be this answer will be useful for somebody else.
We also had such problem in our team and we just created an sbt-plugin for that: sbt-s3-resolver. We were using it for a while and it seems to do it's work fine. It can
Take a look at the usage instructions in readme and open an issue if something is missing.
I was able to get this to work using the sbt-s3 plugin
Here's an example:
import sbt._
import Keys._
import play.Project._
import com.typesafe.sbt.S3Plugin._
import S3._
import sbtassembly.Plugin.AssemblyKeys
import sbtassembly.Plugin.AssemblyKeys._
import sbtassembly.Plugin.assemblySettings
import sbtassembly.Plugin.MergeStrategy
import sbtbuildinfo.Plugin._
object ApplicationBuild extends Build {
val appName = "og-ws"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
anorm,
"com.netflix.astyanax" % "astyanax-cassandra" % "1.56.28",
"com.netflix.astyanax" % "astyanax-thrift" % "1.56.28",
"com.netflix.astyanax" % "astyanax-entity-mapper" % "1.56.28")
val main = (
play.Project(appName, appVersion, appDependencies)
settings (s3Settings: _*)
settings (assemblySettings: _*)
settings (
// call its setters to configure it, see api docs above etc.
publish := (),
publishLocal := (),
mappings in upload <<= dist map { distFile =>
Seq(distFile -> "snapshot/%s/%s/%s-%s.zip".format(appName, appVersion, appName, appVersion))
},
host in upload := "plaor.maven.s3.amazonaws.com",
credentials += Credentials(Path.userHome / ".s3credentials")))
}
s3Settings
? –
Sprage I haven't tried this, but from looking at the api docs, this might work:
project/lib/
, or put "org.springframework.aws" % "spring-aws-ivy" % "1.0"
in project/build.sbt
).Add this to your build.sbt:
{
val s3r = new org.springframework.aws.ivy.S3Resolver
// call its setters to configure it, see api docs above etc.
publishTo := Some(new sbt.RawRepository(s3r)
}
Again, I haven't tried this, but since publishTo
is a SettingKey[Option[Resolver]]
, and RawRepository
extends Resolver
and takes an org.apache.ivy.plugins.resolver.DependencyResolver
, and S3Resolver
implements DependencyResolver
, I'm guessing that it would work.
After all, sbt is really just a wrapper around Apache Ivy.
I too had to do upload an assembly jar to s3 bucket from our build tool. @dres answer helped me to go in the right direction.
I got it working with the following in build.sbt
file.
As you can see, here I have made use of SettingKey[String]
values available in sbt-assembly
// s3Upload
import S3._
s3Settings
mappings in upload := Seq(
(assemblyOutputPath in assembly).value ->
s"${name.value}/${version.value}/${(assemblyJarName in assembly).value}"
)
host in upload := "my-bucket.s3.amazonaws.com"
S3.progress in S3.upload := true
assemblyOutputPath in assembly
gives you the full output path of your assembly jar fileassemblyJarName in assembly
gives you the jar name produced by assembly..value
to get the actual value from SBT keysThis uploads assembly jar to my-bucket
under name/version/name-assembly-version.jar
, with the command sbt s3Upload
.
Note that, I also have set my AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
in the environment. The order in which credentials are looked up can be found here.
© 2022 - 2024 — McMap. All rights reserved.