In order to exclude some dependencies in sbt project, we can use exclude
or excludeAll
method in build.sbt
file.
libraryDependencies ++= Seq(
"org.scalatest" % "scalatest_2.11" % "2.2.0" exclude("org.slf4j", "slf4j-jdk14")
)
While we can pass direct organization and name of package to be exclude to exclude
method, excludeAll
can receive some pattern or rule to be excluded. For example, if you want to exclude all package under org.slf4j
organization, you can create such rule.
val excludeSlf4jBinding = ExclusionRule(organization = "org.slf4j")
libraryDependencies ++= Seq(
"org.scalatest" % "scalatest_2.11" % "2.2.0" excludeAll(excludeSlf4jBinding)
)
This is pretty simple way to exclude multiple transitive dependencies. Of course you can pass muitple rule to excludeAll
method.
libraryDependencies ++= Seq(
"org.scalatest" % "scalatest_2.11" % "2.2.0" excludeAll(
ExclusionRule(organization = ...),
ExclusionRule(organization = ...),
ExclusionRule(organization = ...)
)
)
Please see sbt reference manual in more detail.