2015-07-10 41 views
0

我試圖編譯和使用SBT打包脂肪罐子,我一直運行到下面的錯誤。我已經嘗試了使用庫依賴項排除和合並的一切。衝突的文件中使用SBT組裝

[trace] Stack trace suppressed: run last *:assembly for the full output. 
[error] (*:assembly) deduplicate: different file contents found in the  following: 
[error] /Users/me/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1 .7.10.jar:META-INF/maven/org.slf4j/slf4j-api/pom.properties 
[error] /Users/me/.ivy2/cache/com.twitter/parquet-format/jars/parquet-format-2.2.0-rc1.jar:META-INF/maven/org.slf4j/slf4j-api/pom.properties 
[error] Total time: 113 s, completed Jul 10, 2015 1:57:21 AM 

我build.sbt文件的當前版本低於:

import AssemblyKeys._ 

assemblySettings 

name := "ldaApp" 

version := "0.1" 

scalaVersion := "2.10.4" 

mainClass := Some("myApp") 

libraryDependencies +="org.scalanlp" %% "breeze" % "0.11.2" 

libraryDependencies +="org.scalanlp" %% "breeze-natives" % "0.11.2" 

libraryDependencies += "org.apache.spark" % "spark-mllib_2.10" % "1.3.1" 

libraryDependencies +="org.ini4j" % "ini4j" % "0.5.4" 

jarName in assembly := "myApp" 

net.virtualvoid.sbt.graph.Plugin.graphSettings 

libraryDependencies += "org.slf4j" %% "slf4j-api"" % "1.7.10" % "provided" 

我知道我做錯了什麼......我只是不知道是什麼。

+2

什麼是如此瘋狂?您正在嘗試創建一個胖罐子,並且類路徑中存在重複項。我認爲對於SBT裝配有忽略重複 – vitalii

+0

看到一個不錯的選擇http://stackoverflow.com/questions/25144484/sbt-assembly-deduplication-found-error – vitalii

+0

@ user405887:爲什麼不包括(你的問題)你已經嘗試過?那樣,那些試圖思考的人不會向你展示那種選擇。我在這裏看不到任何雪糕,請在這裏承擔誠意。 –

回答

0

這裏是你如何處理這些問題合併。

import sbtassembly.Plugin._ 

lazy val assemblySettings = sbtassembly.Plugin.assemblySettings ++ Seq(
    publishArtifact in packageScala := false, // Remove scala from the uber jar 
    mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) => 
     { 
      case PathList("META-INF", "CHANGES.txt") => MergeStrategy.first 
      // ... 
      case PathList(ps @ _*) if ps.last endsWith "pom.properties" => MergeStrategy.first 
      case x => old(x) 
     } 
    } 
) 

然後將這些設置添加到您的項目。

lazy val projectToJar = Project(id = "MyApp", base = file(".")).settings(assemblySettings: _*) 
0

我得到了你的裝配生產由脂肪罐子(mllib is already included in spark)去除火花運行。

libraryDependencies += "org.apache.spark" %% "spark-mllib" % "1.3.1" % "provided" 

就像vitalii在評論中說的,這個解決方案已經是here。我明白,花費幾個小時解決問題而無需找到解決辦法可能令人沮喪,但請be nice