Closed ben-manes closed 1 year ago
Same here. Also, a changelog of fixed/changed things would be nice. :)
Same here. This is with the com.github.spotbugs:5.0.13
Gradle plugin.
Seems to work ok from the gui, and i have no idea about gradle, so if someone wants to fix it, i'll merge, otherwise....
Maybe @KengoTODA can help debug this? From the PluginLoader
code, it seems to call the getPluginDescriptor()
before the classLoader has been initialized. The failure seems to occur when it looks for and does not find findbugs.xml
and is generating an exception message with the problematic resource url.
Ran it at command line with debug logging enabled,
The issue is due to the transitive dependencies that were added by this plugin version (jakarta.xml.bind-api
, jakarta.activation-api
). The spotbugs-gradle-plugin
instructs that external plugins should be added to the spotbugsPlugins
configuration, which resolves to include your new dependencies (which should instead be on the classpath). Removing these at the command line succeeds, and therefore removing transitives from the maven resolution fixes the problem.
dependencies.create("com.mebigfatguy.sb-contrib:sb-contrib:${pluginVersions.spotbugsContrib}") {
transitive = false
}
I presume those transitives are only needed if the application uses them too, so it could be provided
scoped. Otherwise, the spotbugs-gradle-plugin
should construct the classpath with the fully resolved dependency and the pluginList
with transitives excluded. The spotbugs-maven-plugin
appears to take an http url to the jar to avoid this problem.
@ben-manes thanks for investigating and posting the fix!
In my case, the issue was fixed by making the following change in build.gradle
dependencies {
// other dependencies omitted
spotbugsPlugins('com.mebigfatguy.sb-contrib:sb-contrib:7.6.0')
}
dependencies {
// other dependencies omitted
spotbugsPlugins('com.mebigfatguy.sb-contrib:sb-contrib:7.6.0') { transitive = false }
}
The main question is, whether jakarta.xml.bind:jakarta.xml.bind-api
should really be a dependency.
If not, so if it should e.g. be provided
like suggested above, this should be fixed here.
Besides that, it is imho a bug in the spotbugs-gradle-plugin
, that it gives the dependencies to the -pluginList
option and not only the actual plugin jars.
For that I opened an issue at spotbugs/spotbugs-gradle-plugin#910 and the underlying issue for the NullPointerException
in SpotBugs is spotbugs/spotbugs#663.
Thanks @KengoTODA for fixing the gradle plugin. Closing as not strictly this plugin's responsibility, though I believe the newly added dependencies were unnecessary and should not have been added by that contributor.
I tried upgrading from 7.4.7, but unfortunately it fails with the error below. This certainly could be my mistake. I verified in the gradle debug log that it has the new jar on the classpath for the project.