2016-08-09 186 views
0

ich habe folgende SBT-Dateien:SBT Assembly - Deduplizierung

. 
-- root 
    -- plugins.sbt 
-- build.sbt 

Mit plugins.sbt mit folgendem Inhalt:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0") 

Und build.sbt folgendes enthält:

import sbt.Keys._ 

resolvers in ThisBuild ++= Seq("Apache Development Snapshot Repository" at "https://repository.apache.org/content/repositories/snapshots/", Resolver.sonatypeRepo("public")) 

name := "flink-experiment" 

lazy val commonSettings = Seq(
    organization := "my.organisation", 
    version := "0.1.0-SNAPSHOT" 
) 

val flinkVersion = "1.1.0" 
val sparkVersion = "2.0.0" 
val kafkaVersion = "0.8.2.1" 

val hadoopDependencies = Seq(
    "org.apache.avro" % "avro" % "1.7.7" % "provided", 
    "org.apache.avro" % "avro-mapred" % "1.7.7" % "provided" 
) 

val flinkDependencies = Seq(
    "org.apache.flink" %% "flink-scala" % flinkVersion % "provided", 
    "org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided", 
    "org.apache.flink" %% "flink-connector-kafka-0.8" % flinkVersion exclude("org.apache.kafka", "kafka_${scala.binary.version}") 
) 

val sparkDependencies = Seq(
    "org.apache.spark" %% "spark-core" % sparkVersion % "provided", 
    "org.apache.spark" %% "spark-streaming" % sparkVersion % "provided", 
    "org.apache.spark" %% "spark-streaming-kafka-0-8" % sparkVersion exclude("org.apache.kafka", "kafka_${scala.binary.version}") 
) 

val kafkaDependencies = Seq(
    "org.apache.kafka" %% "kafka" % "0.8.2.1" 
) 

val toolDependencies = Seq(
    "com.github.scopt" %% "scopt" % "3.5.0" 
) 

val testDependencies = Seq(
    "org.scalactic" %% "scalactic" % "2.2.6", 
    "org.scalatest" %% "scalatest" % "2.2.6" % "test" 
) 

lazy val root = (project in file(".")). 
    settings(commonSettings: _*). 
    settings(
     libraryDependencies ++= hadoopDependencies, 
     libraryDependencies ++= flinkDependencies, 
     libraryDependencies ++= sparkDependencies, 
     libraryDependencies ++= kafkaDependencies, 
     libraryDependencies ++= toolDependencies, 
     libraryDependencies ++= testDependencies 
    ). 
    enablePlugins(AssemblyPlugin) 

run in Compile <<= Defaults.runTask(fullClasspath in Compile, mainClass in(Compile, run), runner in(Compile, run)) 

mainClass in assembly := Some("my.organization.experiment.Experiment") 
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false) 

Jetzt sbt clean assembly traurig gibt die folgende Ausnahme:

[error] (root/*:assembly) deduplicate: different file contents found in the following: 
[error] /home/kevin/.ivy2/cache/org.apache.spark/spark-streaming-kafka-0-8_2.10/jars/spark-streaming-kafka-0-8_2.10-2.0.0.jar:org/apache/spark/unused/UnusedStubClass.class 
[error] /home/kevin/.ivy2/cache/org.apache.spark/spark-tags_2.10/jars/spark-tags_2.10-2.0.0.jar:org/apache/spark/unused/UnusedStubClass.class 
[error] /home/kevin/.ivy2/cache/org.spark-project.spark/unused/jars/unused-1.0.0.jar:org/apache/spark/unused/UnusedStubClass.class 

Wie kann ich das beheben?

Antwort

1

Sie können die Standardstrategie für Konflikte außer Kraft setzen:

val defaultMergeStrategy: String => MergeStrategy = { 
    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 "services" :: xs => 
      MergeStrategy.filterDistinctLines 
     case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) => 
      MergeStrategy.filterDistinctLines 
     case _ => MergeStrategy.deduplicate 
     } 
    case _ => MergeStrategy.deduplicate 
    } 

wie Sie Montage Standardstrategie ist MergeStrategy.deduplicate sehen können, Sie einen neuen Fall case UnusedStubClass => MergeStrategy.first

+0

Danke! Ich versuche nun folgende: val defaultMergeStrategy: String => MergeStrategy = { case "UnusedStubClass" => MergeStrategy.first Fall x wenn Assembly.isConfigFile (x) => MergeStrategy.concat Aber das gibt mir die gleicher Fehler Was mache ich falsch? –

+0

können Sie versuchen: '{case x: String wenn x.contains (" UnusedStubClass ") => MergeStrategy.first' – kpbochenek