Scalatra独立部署无法创建程序集

时间:2013-08-22 16:33:00

标签: scala sbt scalatra sbt-assembly

当我按照Scalatra文档(http://www.scalatra.org/2.2/guides/deployment/standalone.html)的方式运行“assembly”命令时,我收到以下错误:

[trace] Stack trace suppressed: run last *:assembly for the full output.
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] /home/nick/.ivy2/cache/org.eclipse.jetty.orbit/javax.servlet/orbits/javax.servlet-3.0.0.v201112011016.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-continuation/jars/jetty-continuation-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-http/jars/jetty-http-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-io/jars/jetty-io-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-security/jars/jetty-security-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-server/jars/jetty-server-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-servlet/jars/jetty-servlet-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-util/jars/jetty-util-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-webapp/jars/jetty-webapp-8.1.8.v20121106.jar:about.html
[error] /home/nick/.ivy2/cache/org.eclipse.jetty/jetty-xml/jars/jetty-xml-8.1.8.v20121106.jar:about.html

这意味着什么,以及如何解决?

这是我的构建文件,合并策略设置为第一个:

import sbt._

import Keys._

import org.scalatra.sbt._

import org.scalatra.sbt.PluginKeys._

import com.mojolly.scalate.ScalatePlugin._

import ScalateKeys._

import sbtassembly.Plugin._

import AssemblyKeys._



object MyScalatraWebAppBuild extends Build {

  val Organization = "com.example"

  val Name = "My Scalatra Web App"

  val Version = "0.1.0-SNAPSHOT"

  val ScalaVersion = "2.10.2"

  val ScalatraVersion = "2.2.1"



  mergeStrategy in assembly := mergeStrategy.first

  jarName in assembly := "scalatra_atmosphere_demo.jar"



      lazy val project = Project (

        "my-scalatra-web-app",

        file("."),

        settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraWithJRebel ++ scalateSettings ++ assemblySettings ++ Seq(

          organization := Organization,

          name := Name,

          version := Version,

          scalaVersion := ScalaVersion,

          resolvers += Classpaths.typesafeReleases,

          libraryDependencies ++= Seq(

            "org.scalatra" %% "scalatra" % ScalatraVersion,

            "org.scalatra" %% "scalatra-scalate" % ScalatraVersion,

            "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",

            "ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",

            "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container;compile",

            "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")),

            "org.scalatra" %% "scalatra-atmosphere" % "2.2.1",

            "org.scalatra" %% "scalatra-json" % "2.2.1",

            "org.json4s"   %% "json4s-jackson" % "3.2.4",

            "org.eclipse.jetty" % "jetty-websocket" % "8.1.10.v20130312" % "container" 

          ),

          scalateTemplateConfig in Compile <<= (sourceDirectory in Compile){ base =>

            Seq(

              TemplateConfig(

                base / "webapp" / "WEB-INF" / "templates",

                Seq.empty,  /* default imports should be added here */

                Seq(

                  Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)

                ),  /* add extra bindings here */

                Some("templates")

              )

            )

          },

          resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

        ) 

      ) 

1 个答案:

答案 0 :(得分:1)

首先,在build.scala中,每行之间不必有空行。

其次,sbt-assembly的设置需要成为项目设置的一部分,因此您必须将其包含在Seq(...)的某个位置。

第三,你的合并策略不会起作用,因为类型不正确,你通常不能先找到所有东西。你应该尝试类似的东西:

Seq(
  organization := Organization,
  name := Name,
  ....

  jarName in assembly := "scalatra_atmosphere_demo.jar",
  mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
    {
      case PathList(xs @ _*) if xs.last endsWith ".html" => MergeStrategy.first
      case x => old(x)
    }
  }
)