sbt使用'exclude'排除工件

时间:2017-07-12 07:16:01

标签: scala sbt sbt-assembly

我希望在build.scala中使用sbt模式从jar中排除神器。我看过很少的帖子,但仍然没有线索。

  [error] deduplicate: different file contents found in the following:
  [error] /home/me/.ivy2/cache/com.datastax.spark/spark-cassandra-connector_2.10/jars/spark-cassandra-connector_2.10-2.0.3.jar:org/objectweb/asm/signature/SignatureWriter.class
  [error] /home/me/.ivy2/cache/org.ow2.asm/asm/jars/asm-5.0.4.jar:org/objectweb/asm/signature/SignatureWriter.class
  [error] deduplicate: different file contents found in the following:
  [error] /home/me/.ivy2/cache/com.datastax.spark/spark-cassandra-connector_2.10/jars/spark-cassandra-connector_2.10-2.0.3.jar:org/objectweb/asm/signature/SignatureVisitor.class
  [error] /home/me/.ivy2/cache/org.ow2.asm/asm/jars/asm-5.0.4.jar:org/objectweb/asm/signature/SignatureVisitor.class

我想排除org/objectweb/asm

我累了

libraryDependencies ++= Seq(
...
"com.datastax.spark"  %% "spark-cassandra-connector"  % "2.0.3"  exclude("org.objectweb", "asm"), 
...)

1 个答案:

答案 0 :(得分:2)

你应该像

那样做
libraryDependencies ++= Seq(
...
"com.datastax.spark"  %% "spark-cassandra-connector"  % "2.0.3"  exclude("org.objectweb.asm", "org.objectweb.asm"), 
...)

你也可以这样做

libraryDependencies ++= Seq(
...
"com.datastax.spark"  %% "spark-cassandra-connector"  % "2.0.3", 
...).map(_.exclude("org.objectweb.asm", "org.objectweb.asm"))

如果您使用sbt 0.13.8及更高版本,则可以执行

libraryDependencies ++= Seq(
...
"com.datastax.spark"  %% "spark-cassandra-connector"  % "2.0.3", 
...)

excludeDependencies += "org.objectweb.asm" % "org.objectweb.asm"