I'm trying to test the behavior of a logger with JUnit and SLF4J Test, which is "a test implementation of SLF4J that stores log messages in memory and provides methods for retrieving them".
From the SLF4J Test docs:
SLF4J Test should be the only SLF4J implementation on your test classpath
I have a few dependencies that have SLF4J as a transitive dependency. I'm trying to exclude SLF4J from all dependencies in my test configuration, but I still need it for SLF4J Test.
I can exclude SLF4J from everything with the below code, but this obviously also excludes it from SLF4J Test, where I need it.
configurations {
testCompile.exclude group: "org.slf4j"
}
As SLF4J is a transitive dependency of many of my other dependencies, including Spring Boot, it isn't practical (or possible?) to go through and individually exclude it from all of them.
Is there a (relatively painless) way I can exclude a transitive dependency from all dependencies except the one that needs it?