Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLF4j warnings when running with gradle 5.3 #136

Closed
madorb opened this issue Mar 29, 2019 · 9 comments
Closed

SLF4j warnings when running with gradle 5.3 #136

madorb opened this issue Mar 29, 2019 · 9 comments

Comments

@madorb
Copy link

madorb commented Mar 29, 2019

Using gradle 5.3.1 and spotbugs gradle plugin 1.7.1. Every time i run my build i get the following warnings.

Others have reported this on closed ticket spotbugs/spotbugs#823

> Task :web:spotbugsMain
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

> Task :wsclient:spotbugsMain
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
@welcome
Copy link

welcome bot commented Mar 29, 2019

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.

@KengoTODA KengoTODA transferred this issue from spotbugs/spotbugs Apr 1, 2019
@oneiros-de
Copy link

Looks like a duplicate of #133

@bhelm-zoccam
Copy link

bhelm-zoccam commented Jun 28, 2019

Still a problem in Gradle 5.4.1 w/Spotbugs 4.0.0-beta2.

Adding slf4j to build classpath in Gradle does not help.

@baev
Copy link

baev commented Apr 3, 2020

the problem is that plugin adds slf4-simple dependency with fixed version 1.8.0-beta4 https://github.com/spotbugs/spotbugs-gradle-plugin/blob/master/build.gradle#L28 when Spring Boot uses dependency management plugin to import slf4 version from Spring Boot Parent pom (spring-boot-starter-parent) which is 1.7.30 (as for version 2.2.6.RELEASE). So the result classpath of spotbugs looks like this:

~/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.8.0-beta4/1531950ac50afd70a4d02f10b6aaf6d6a6a7669e/slf4j-simple-1.8.0-beta4.jar
~/.gradle/caches/modules-2/files-2.1/com.github.spotbugs/spotbugs/3.1.12/f44d1e64d96d683cc930622f1cc23b87a0bcd299/spotbugs-3.1.12.jar
~/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.30/b5a4b6d16ab13e34a88fae84c35cd5d68cac922c/slf4j-api-1.7.30.jar
~/.m2/repository/org/ow2/asm/asm-commons/7.0/asm-commons-7.0.jar
~/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/7.0/18d4d07010c24405129a6dbb0e92057f8779fb9d/asm-util-7.0.jar
~/.m2/repository/org/ow2/asm/asm-analysis/7.0/asm-analysis-7.0.jar
~/.m2/repository/org/ow2/asm/asm-tree/7.0/asm-tree-7.0.jar
~/.m2/repository/org/ow2/asm/asm/7.0/asm-7.0.jar
~/.gradle/caches/modules-2/files-2.1/org.apache.bcel/bcel/6.3/ab01e21304edb070aa840b856a4b26f17f901479/bcel-6.3.jar
~/.m2/repository/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar
~/.m2/repository/org/dom4j/dom4j/2.1.1/dom4j-2.1.1.jar
~/.gradle/caches/modules-2/files-2.1/jaxen/jaxen/1.2.0/c10535a925bd35129a4329bc75065cc6b5293f2c/jaxen-1.2.0.jar
~/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
~/.gradle/caches/modules-2/files-2.1/com.github.spotbugs/spotbugs-annotations/3.1.12/ba2c77a05091820668987292f245f3b089387bfa/spotbugs-annotations-3.1.12.jar
~/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar

slf4j-simple-1.8.0-beta4.jar is not compatible with slf4j-api-1.7.30.jar that causes warning.

The possible workaround is to configure gradle dependency management plugin (https://plugins.gradle.org/plugin/io.spring.dependency-management) to use slf4j version 1.8.0-beta4 or manually override spotbugs classpath by using afterEvaluate hook for spotbugs gradle plugin:

afterEvaluate {
  val spotbugs = configurations.getByName("spotbugs")
  dependencies {
    spotbugs("org.slf4j:slf4j-nop") // or org.slf4j:slf4j-simple, correct version will be provided by  dependency management plugin 
    spotbugs("com.github.spotbugs:spotbugs:3.1.12")
  }
}

@KengoTODA
Copy link
Member

It is also possible to use spotbugsSlf4j configuration, then we can change the dependency for SLF4J provider:

dependencies {
  spotbugsSlf4j  "org.slf4j:slf4j-simple:1.7.30"
}

@jscancella
Copy link
Contributor

@madorb is this still an issue?

@madorb
Copy link
Author

madorb commented Mar 29, 2021

does not appear to be an issue anymore, no warnings using latest gradle

@martmagi
Copy link

FYI, this issue is back with Gradle 7.3.1 and Spotbugs Gradle Plugin 5.0.3.

> Task :spotbugsMain
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

> Task :spotbugsTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

@KengoTODA
Copy link
Member

@martmagi this repo itself meets the condition you pointed but no warning was reported.

https://github.com/spotbugs/spotbugs-gradle-plugin/runs/4544294283

Try to make a mcve project, and create a new issue with it.

@spotbugs spotbugs locked as resolved and limited conversation to collaborators Dec 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants