Hey! Adding `testImplementation` dependency on `Gr...
# gradle
p
Hey! Adding
testImplementation
dependency on
Gradle API
triggers a conflict of loggers and blocks further work, since
SLF4J: Class path contains multiple SLF4J bindings.
Is it possible to “cut off” the gradle logger so it won’t be on the classpath? Some context related details: • It’s added just as a dependency
testImplementation(gradleApi())
• The goal of adding Gradle API is for enabling an ability to run some custom gradle tasks during integration/end-to-end testing (I’m using JUnit) • It doesn’t seem possible to exclude the logger as it’s built-in into the Gradle source, so it seems not even a dedicated module that could be possible to just exclude from the build 🤷‍♂️ an error messages:
Copy code
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:$HOME/.gradle/caches/7.5/generated-gradle-jars/gradle-api-7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:$HOME/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.11/4741689214e9d1e8408b206506cbe76d1c6a7d60/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See <http://www.slf4j.org/codes.html#multiple_bindings> for an explanation.
SLF4J: Actual binding is of type [org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext]
...
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext loaded from file:$HOME/.gradle/caches/7.5/generated-gradle-jars/gradle-api-7.5.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext
...
Please suggest what are the options to resolve this conflict which 🙏
v
To run a Gradle task the dependency is wrong. That dependency is for developing a Gradle task or plugin. If you want to run a Gradle task, ist the tooling API standalone, not from the
gradleApi()
.
p
@Vampire thanks for the suggestion 🙏 it did the trick
116 Views