2

当我按照 Scalatra 文档(http://www.scalatra.org/2.2/guides/deployment/standalone.html)的指示运行“程序集”命令时,出现以下错误:

[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/"

        ) 

      ) 
4

1 回答 1

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)
    }
  }
)
于 2013-08-22T18:09:48.417 回答