2014-10-10 41 views
1

嘗試運行assembly時出現重複數據刪除錯誤。我已經使用了一些對我的合併策略不同的方法來嘗試解決這一問題,但沒有人似乎工作..合併策略不適用於sbt-assembly的重複數據刪除問題

SBT輸出錯誤

[warn] Merging 'META-INF\DUMMY.DSA' with strategy 'discard' 
[warn] Merging 'META-INF\DUMMY.SF' with strategy 'discard' 
[warn] Merging 'META-INF\ECLIPSEF.SF' with strategy 'discard' 
[warn] Merging 'META-INF\INDEX.LIST' with strategy 'discard' 
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard' 
[warn] Merging 'META-INF\services\java.sql.Driver' with strategy 'filterDistinctLines' 
[warn] Merging 'META-INF\spring.handlers' with strategy 'filterDistinctLines' 
[warn] Merging 'META-INF\spring.schemas' with strategy 'filterDistinctLines' 
[debug] Merging 'META-INF\spring.tooling' with strategy 'deduplicate' 
java.lang.RuntimeException: deduplicate: different file contents found in the following: 
C:\Users\Matthew\.ivy2\cache\org.springframework\spring-jdbc\jars\spring-jdbc-4.0.5.RELEASE.jar:META-INF/spring.tooling 
C:\Users\Matthew\.ivy2\cache\org.springframework\spring-beans\jars\spring-beans-4.0.5.RELEASE.jar:META-INF/spring.tooling 
C:\Users\Matthew\.ivy2\cache\org.springframework\spring-tx\jars\spring-tx-4.0.5.RELEASE.jar:META-INF/spring.tooling 

和build.scala

import com.mojolly.scalate.ScalatePlugin.ScalateKeys._ 
import com.mojolly.scalate.ScalatePlugin._ 
import org.scalatra.sbt._ 
import sbt.Keys._ 
import sbt._ 
import sbtassembly.Plugin._ 
import sbtassembly.Plugin.AssemblyKeys._ 

object ScalatraBuild extends Build { 
    val Organization = "com.my.myproject" 
    val Name = "myproject" 
    val Version = "0.1.0-SNAPSHOT" 
    val ScalaVersion = "2.11.1" 
    val ScalatraVersion = "2.3.0" 
    val port = SettingKey[Int]("port") 
    val Conf = config("container") 

    lazy val project = Project(
     "myproject-platform", 
     file("."), 
     settings = Defaults.defaultConfigs ++ ScalatraPlugin.scalatraWithJRebel ++ net.virtualvoid.sbt.graph.Plugin.graphSettings ++ scalateSettings ++ assemblySettings ++ Seq(
      port in Conf := 8080, 
      organization := Organization, 
      name := Name, 
      version := Version, 
      scalaVersion := ScalaVersion, 
      resolvers ++= Seq("Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/", 
       "RoundEights" at "http://maven.spikemark.net/roundeights", 
       Resolver.sonatypeRepo("releases")), 
      libraryDependencies ++= Seq(
       "org.scala-lang" % "scala-compiler" % "2.11.1", 
       "org.scalatra" %% "scalatra" % ScalatraVersion, 
       "org.scalatra" %% "scalatra-scalate" % ScalatraVersion, 
       "org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test", 
       "org.scalatra" %% "scalatra-auth" % "2.3.0", 
       "org.scalatra" %% "scalatra-json" % "2.3.0", 
       "org.json4s" %% "json4s-jackson" % "3.2.10", 
       "org.json4s" %% "json4s-ext" % "3.2.10", 
       "org.json4s" %% "json4s-core" % "3.2.10", 
       "com.chuusai" %% "shapeless" % "2.0.0", 
       "com.github.julien-truffaut" %% "monocle-core" % "0.5.1", 
       "com.github.julien-truffaut" %% "monocle-generic" % "0.5.1", 
       "com.github.julien-truffaut" %% "monocle-macro" % "0.5.1", 
       "com.roundeights" %% "mailgun-scala" % "0.2", 
       "com.roundeights" %% "scalon" % "0.2", 
       "net.databinder.dispatch" %% "dispatch-core" % "0.11.1", 
       "com.escalatesoft.subcut" %% "subcut" % "2.1", 
       "com.typesafe" % "config" % "1.2.1", 
       "ch.qos.logback" % "logback-classic" % "1.0.13" % "runtime", 
       "org.codehaus.janino" % "janino" % "2.6.1", 
       "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container;compile", 
       "org.apache.derby" % "derby" % "10.10.1.1", 
       "c3p0" % "c3p0" % "0.9.1.2", 
       "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "compile;container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")), 
       "com.googlecode.mapperdao" %% "mapperdao" % "1.0.1", 
       "mysql" % "mysql-connector-java" % "5.1.18", 
       "commons-dbcp" % "commons-dbcp" % "1.4", 
       "com.stripe" % "stripe-java" % "1.18.0" 
      ), 
      mergeStrategy in assembly <<= (mergeStrategy in assembly) { 
       (old) => { 
        case PathList([email protected]_*) if xs.last endsWith ".tooling" => MergeStrategy.first 
        case PathList("META-INF", "spring.tooling") => MergeStrategy.first 
        case PathList("META-INF", xs @ _*) => 
        (xs map {_.toLowerCase}) match { 
         case "spring.tooling" :: Nil => MergeStrategy.first 
        } 
        case x => old(x) 
       } 
      }, 
       scalateTemplateConfig in Compile <<=(sourceDirectory in Compile) { base => 
       Seq(
        TemplateConfig(
         base/"webapp"/"WEB-INF"/"templates", 
         Seq.empty, /* default imports should be added here */ 
         Seq.empty, /* add extra bindings here */ 
         Some("templates") 
        ) 
       ) 
      } 
     ) 
    ) 
} 

正如你可以看到我已經嘗試了幾個不同的東西,但他們都沒有看到匹配的情況。我可以得到一些幫助嗎?

回答

0

我在我的項目的根目錄中使用了assembly.sbt文件,但在build.scala中指定了合併策略設置。一旦我將設置移動到這個文件,一切正常。

2

試試這個

case x if x.endsWith("spring.tooling") => MergeStrategy.last 

對於我建立的文件看起來不錯,但你可以嘗試添加「的println」語句,看看實際的自定義合併策略時,也許SBT組裝沒有看到它

+0

我在'case x'匹配中添加了'println'語句,但它沒有觸發......您是否認爲將項目根目錄中的設置移動到自己的'assembly.sbt'會有所幫助?畢竟這是一個單一的模塊項目.. – 2014-10-11 03:41:34