user375566
user375566

Reputation:

Play 2.0 - Build.scala - converting from pom.xml

I'm trying to migrate from a Nexus maven repo to using https://github.com/jcaddel/maven-s3-wagon. Getting on the wagon? I've read some things about build scripts for SBT, but that doesn't seem like what I want...am I missing something? Documentation is sparse.

Here is my Play! 2.0 Build.scala file:

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

  val appName = "my-play-app"
  val appVersion = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    "org.fusesource.mqtt-client" % "mqtt-client" % "1.0")

  val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
    resolvers ++= Seq(
      "Maven Repository" at "http://repo1.maven.org/maven2/",
      "fusesource.snapshots" at "http://repo.fusesource.com/nexus/content/repositories/snapshots",
      "fusesource.releases" at "http://repo.fusesource.com/nexus/content/groups/public"))
}

Here is what I need to convert from the pom.xml file to Build.scala (via the wagon wiki):

<build>
 <extensions>
  <extension>
    <groupId>org.kuali.maven.wagons</groupId>
    <artifactId>maven-s3-wagon</artifactId>
    <version>[S3 Wagon Version]</version>
  </extension>
 </extensions>
</build>

And

<distributionManagement>
 <site>
  <id>s3.site</id>
  <url>s3://[AWS Bucket Name]/site</url>
 </site>
 <repository>
  <id>s3.release</id>
  <url>s3://[AWS Bucket Name]/release</url>
 </repository>
 <snapshotRepository>
  <id>s3.snapshot</id>
  <url>s3://[AWS Bucket Name]/snapshot</url>
 </snapshotRepository>
</distributionManagement>

I think I understand how to add the distribution portion to Build.scala:

    import sbt._
    import Keys._
    import PlayProject._

    object ApplicationBuild extends Build {

      val appName = "my-play-app"
      val appVersion = "1.0-SNAPSHOT"

      val appDependencies = Seq(
        "org.fusesource.mqtt-client" % "mqtt-client" % "1.0")

      val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
        resolvers ++= Seq(
          "Maven Repository" at "http://repo1.maven.org/maven2/",
          "fusesource.snapshots" at "http://repo.fusesource.com/nexus/content/repositories/snapshots",
          "fusesource.releases" at "http://repo.fusesource.com/nexus/content/groups/public",
          "s3.site" at "s3://[AWS Bucket Name]/site",
          "s3.release" at "s3://[AWS Bucket Name]/release",
          "s3.snapshot" at "s3://[AWS Bucket Name]/snapshot"))
    }

Upvotes: 2

Views: 1231

Answers (4)

Magnus Eklund
Magnus Eklund

Reputation: 649

A combination of sbt-aether-deploy, maven-s3-wagon and fmt-sbt-s3-resolver works well for me

build.sbt:

publishMavenStyle := true

publishTo <<= version { v: String =>

  if (v.trim.endsWith("SNAPSHOT"))
    Some("Snapshots" at "s3://myrepo/snapshots")
  else
    Some("Releases" at "s3://myrepo/releases")
}

aetherSettings

aetherPublishSettings

wagons := Seq(aether.WagonWrapper("s3", "org.kuali.maven.wagon.S3Wagon"))

plugins.sbt:

addSbtPlugin("no.arktekk.sbt" % "aether-deploy" % "0.13")

addSbtPlugin("com.frugalmechanic" % "fm-sbt-s3-resolver" % "0.4.0")

libraryDependencies += "org.kuali.maven.wagons" % "maven-s3-wagon" % "1.2.1"

fm-sbt-s3-resolver is used for resolving s3 dependencies and aether for deploy. Deployment with fm-sbt-s3-resolver alone will not AFAIK generate and publish metadata (maven-metadata.xml)

Upvotes: 1

stefan.schwetschke
stefan.schwetschke

Reputation: 8932

It looks like there is still no automatic S3 publish support in sbt (although there is a s3-plugin). But I think you can easily create your own, given that

  1. sbt can be enhanced with plugins
  2. Maven plugins are just POJOs (so you can easily reuse them outside of maven)
  3. There is an existing Maven plugin that already does what you want

I think you can

  1. Use the sbt release plugin...
  2. ...add your own custom release step...
  3. ...that calls S3Wagon.putResource or S3Plugin.S3.s3Settings.upload

Upvotes: 1

joescii
joescii

Reputation: 6533

There is an S3 Plugin for sbt available.

Upvotes: 0

S-C
S-C

Reputation: 1929

Sbt doesn't support maven extensions which is what gives you the s3:// protocol, so in short there is no easy way to do what you are trying to do

Upvotes: 0

Related Questions