在sbt-assembly

时间:2015-04-25 17:27:08

标签: java playframework playframework-2.0 sbt-assembly

问题:为什么忽略MergeStrategy.first?

我使用版本2.3.8在Play Framework中制作了一个小应用程序 根据官方文档,您可以将行addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")添加到plugin.sbt并添加一些(请参阅下面的代码)以使用activator assembly命令。

这似乎有效,但存在重复数据删除冲突。这与文件ServerWithStop.class奇怪地发生。在build.sbt中,这个类有一个assembleMergeStrategy。这是官方文档的精确副本。

case "play/core/server/ServerWithStop.class" => MergeStrategy.first
case other => (assemblyMergeStrategy in assembly).value(other)

我添加了几行我发现修复spring.tooling重复数据删除(可以在完整的sbt中再次找到)。 我明白这些原则;它的散列SHA-1比较类然后根据行为合并,我明白它不明白如何处理与ServerWithStop.class似乎不同的重复项。

我不理解(因此问题):为什么它忽略了MergeStrategy.first?

-

build.sbt

name := """MovieRequest"""

version := "1.0"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs,
  "mysql" % "mysql-connector-java" % "5.1.35"
)

mainClass in assembly := Some("play.core.server.NettyServer")

fullClasspath in assembly += Attributed.blank(PlayKeys.playPackageAssets.value)

assemblyExcludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
  cp filter {x => x.data.getName.matches("sbt.*") || x.data.getName.matches(".*macros.*")}
}

// Exclude commons-logging because it conflicts with the jcl-over-slf4j
libraryDependencies ~= { _ map {
  case m if m.organization == "com.typesafe.play" =>
m.exclude("commons-logging", "commons-logging")
  case m => m
}}

assemblyMergeStrategy in assembly := {
  case x if Assembly.isConfigFile(x) =>
    MergeStrategy.concat
  case PathList(ps @ _*) if Assembly.isReadme(ps.last) || Assembly.isLicenseFile(ps.last) =>
MergeStrategy.rename
  case PathList("META-INF", xs @ _*) =>
(xs map {_.toLowerCase}) match {
  case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) =>
    MergeStrategy.discard
      case ps @ (x :: xs) if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa")     =>
        MergeStrategy.discard
      case "plexus" :: xs =>
        MergeStrategy.discard
      case "spring.tooling" :: xs =>
        MergeStrategy.discard
      case "services" :: xs =>
        MergeStrategy.filterDistinctLines
      case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) =>
        MergeStrategy.filterDistinctLines
      case _ => MergeStrategy.deduplicate
    }
  case "asm-license.txt" | "overview.html" => MergeStrategy.discard

  // Take the first ServerWithStop because it's packaged into two jars
  case "play/core/server/ServerWithStop.class" => MergeStrategy.first
  case other => (assemblyMergeStrategy in assembly).value(other)
}

0 个答案:

没有答案