Scala – How to exclude commons-logging from a scala/sbt/slf4j project

sbtscalaslf4j

My scala/sbt project uses grizzled-slf4j and logback. A third-party dependency uses Apache Commons Logging.

With Java/Maven, I would use jcl-over-slf4j and logback-classic so that I can use logback as the unified logging backend.

I would also eliminate the commons-logging dependency that the third-party lib would let sbt pull in. I do the following in Maven (which is recommended by http://www.slf4j.org/faq.html#excludingJCL):

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
</dependency>

And the question is, how to do the same with sbt?

Best Answer

Heiko's approach will probably work, but will lead to none of the dependencies of the 3rd party lib to be downloaded. If you only want to exclude a specific one use exclude.

libraryDependencies += "foo" % "bar" % "0.7.0" exclude("org.baz", "bam")

or

... excludeAll( ExclusionRule(organization = "org.baz") ) // does not work with generated poms!
Related Topic