I’m trying to include the Spark web framework in my project, however it uses slf4j-simple which doesn’t support the logback file. What I am trying to do is exclude slf4j-simple and then include slf4j-api and logback-classic as separate dependencies. Someone posted the build script to do that here but it’s for Maven. Here it is:
It’s not clear what you’re trying to accomplish here. Your attempted exclude (slf4j) doesn’t match what you’ve said you’re trying to exclude (slf4j-simple). The Gradle equivalent of the Maven spark-core reference would be:
However, your posted build.gradle specifies com.sparkjava:spark-core:2.7.2, which doesn’t depend on slf4j-simple at all. The slf4j-simple dependency was removed starting with 2.4, so excluding it with recent versions won’t change anything.
I did try slf4j-simple, too but I gave it another shot just now and it is still showing in the built jar… For reference, here’s my current build script and a screenshot of the built jar’s contents after running gradlew shadow
You said that you are trying to exclude slf4j-simple. However, the JAR built from what you shared does not contain slf4j-simple. The dependency versions you’re using don’t even depend on slf4j-simple, so even if you remove the exclude, slf4j-simple won’t be included.
With the information you’ve provided, there doesn’t appear to be any way that your problem is actually related to slf4j-simple. The information about excluding slf4j-simple in Maven is only applicable to older versions of the Spark web framework than what you’re using. The exclude you have would work if that’s what you needed. If you share whatever error you’re seeing, it may help determine what you might actually need to change.
I don’t think anything is including slf4j-simple in your build at all. I think you’re confusing information you found about a slf4j-simple issue that applies to older versions of the Spark web framework with what you’re seeing.
My understanding is that you don’t want:
slf4j-simple - You don’t have it, even without the exclude.
But you want:
slf4j-api - You do have it, it’s a transitive dependency of spark-core
logback-classic - Not a direct or transitive dependency of your dependencies {}
Are you actually seeing a problem, or are you just expecting to see something different than what you’re seeing before adding logback-classic?