2

I am looking to exclude artifact from jar with sbt pattern in build.scala. I have seen few posts but have no clue still.

  [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

I'd like to exclude org/objectweb/asm

I tired

libraryDependencies ++= Seq(
...
"com.datastax.spark"  %% "spark-cassandra-connector"  % "2.0.3"  exclude("org.objectweb", "asm"), 
...)
Toren
  • 6,648
  • 12
  • 41
  • 62

1 Answers1

2

you should have done it like

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

you can also do it as

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

if you are using sbt 0.13.8 and above then you can do

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

excludeDependencies += "org.objectweb.asm" % "org.objectweb.asm"
Ramesh Maharjan
  • 41,071
  • 6
  • 69
  • 97
  • What's the rule ? why `"org.objectweb.asm"` twice ? – Toren Jul 12 '17 at 08:35
  • Still have the same problem after `reload`,`update`,`assembly` – Toren Jul 12 '17 at 08:41
  • I was guessing the dependency you want to exclude is https://mvnrepository.com/artifact/org.objectweb.asm/org.objectweb.asm/3.3.1.v201105211655. is it not? did you try all the methods? – Ramesh Maharjan Jul 12 '17 at 09:00
  • I want to exclude the `org.objectweb.asm` only from one artifact , let it be `spark-cassandra-connector` and keep it in another `org.ow2.asm`, I think two other methods will remove the `org.objectweb.asm` at all . Am I wrong ? – Toren Jul 12 '17 at 09:26