Play 2.0 - Build.scala - 从pom.xml转换

时间:2012-05-02 05:45:31

标签: scala maven sbt playframework-2.0

我正在尝试从Nexus maven repo迁移到使用https://github.com/jcaddel/maven-s3-wagon。上车?我已经阅读了一些关于SBT构建脚本的内容,但这看起来不像我想要的......我错过了什么吗?文档很少。

这是我的游戏! 2.0 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"))
}

以下是我需要从pom.xml文件转换为Build.scala(通过wagon wiki):

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

并且

<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>

我想我了解如何将分发部分添加到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"))
    }

4 个答案:

答案 0 :(得分:1)

看起来在sbt中仍然没有自动S3发布支持(尽管有s3-plugin)。但我认为你可以轻松创建自己的,

  1. 可以使用插件增强sbt
  2. Maven插件只是POJO(因此您可以轻松地在maven之外重用它们)
  3. 有一个existing Maven plugin已经做了你想要的事情
  4. 我认为你可以

    1. 使用sbt release plugin ...
    2. ...添加您自己的自定义发布步骤...
    3. ...调用S3Wagon.putResourceS3Plugin.S3.s3Settings.upload

答案 1 :(得分:1)

sbt-aether-deploymaven-s3-wagonfmt-sbt-s3-resolver的组合适用于我

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用于解析s3依赖关系和以太用于部署。仅使用fm-sbt-s3-resolver部署AFAIK不会生成和发布元数据(maven-metadata.xml)

答案 2 :(得分:0)

Sbt不支持maven扩展,它提供了s3://协议,所以简而言之,没有简单的方法可以做你想做的事情

答案 3 :(得分:0)

S3 Plugin for sbt可用。