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

NullPointerException in PluginLoader #19

Open
boris-petrov opened this issue Jun 14, 2017 · 7 comments
Open

NullPointerException in PluginLoader #19

boris-petrov opened this issue Jun 14, 2017 · 7 comments

Comments

@boris-petrov
Copy link

Hi, I'm using Gradle 3.5 and FindBugs 3.0.1 with a couple of other plugins. This is my configuration:

findbugs 'com.google.code.findbugs:findbugs:3.0.1'
findbugs configurations.findbugsPlugins.dependencies
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.6.0'
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.0.2'
findbugsPlugins 'com.monits:findbugs-plugin:0.2.0'

Without the last line, everything works as expected. When I include it, I get:

Caused by: java.lang.NullPointerException
        at edu.umd.cs.findbugs.PluginLoader.getPluginDescriptor(PluginLoader.java:1168)
        at edu.umd.cs.findbugs.PluginLoader.init(PluginLoader.java:653)
        at edu.umd.cs.findbugs.PluginLoader.<init>(PluginLoader.java:211)
        at edu.umd.cs.findbugs.PluginLoader.getPluginLoader(PluginLoader.java:1359)
        at edu.umd.cs.findbugs.Plugin.addCustomPlugin(Plugin.java:684)
        at edu.umd.cs.findbugs.Plugin.addCustomPlugin(Plugin.java:676)
        at edu.umd.cs.findbugs.Plugin.loadCustomPlugin(Plugin.java:668)
        at edu.umd.cs.findbugs.Plugin.loadCustomPlugin(Plugin.java:661)
        at edu.umd.cs.findbugs.FindBugsCommandLine.handleOptionWithArgument(FindBugsCommandLine.java:148)
        at edu.umd.cs.findbugs.TextUICommandLine.handleOptionWithArgument(TextUICommandLine.java:573)
        at edu.umd.cs.findbugs.config.CommandLine.parse(CommandLine.java:340)
        at edu.umd.cs.findbugs.config.CommandLine.parse(CommandLine.java:307)
        at edu.umd.cs.findbugs.FindBugs.processCommandLine(FindBugs.java:347)
        at org.gradle.api.plugins.quality.internal.findbugs.FindBugsExecuter.runFindbugs(FindBugsExecuter.java:38)

Am I doing something wrong?

@jsotuyod
Copy link
Member

That's interesting... that's pretty much how we do it ourselves (we use our own gradle plugin, you can check the code here)

We do (redacted version)

        project.dependencies.with {
            add('findbugsPlugins',
                    'com.monits:findbugs-plugin:0.2.0') { ModuleDependency d ->
                d.transitive = false
            }

            add('findbugsPlugins', 'com.mebigfatguy.fb-contrib:fb-contrib:7.0.1')
        }

Notice that defining the findbugsPlugins configuration is not necessary, nor adding those dependencies to the findbugs configuration.

I'd try changing your snippet to just

findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.6.0'
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.0.2'
findbugsPlugins 'com.monits:findbugs-plugin:0.2.0

and see what happens. You could also try our plugin, but shouldn't make a difference towards this issue...

@boris-petrov
Copy link
Author

Ok, so I've fixed it by adding a:

findbugsPlugins('com.monits:findbugs-plugin:0.2.0') { ModuleDependency d ->
	d.transitive = false
}

I have no idea what this does but without it I couldn't make it work in any other way. It's the same with your code (the redacted version you pasted) - if you remove this transitive = false thing - it blows up with a NPE.

I'll leave this issue open and let you decide whether it should be closed or you're going to investigate it more. Thanks for the support!

@jsotuyod
Copy link
Member

Just to be sure, have you tried removing findbugs configurations.findbugsPlugins.dependencies?

@boris-petrov
Copy link
Author

Yes, I tried and the same thing happens - NPE.

@jsotuyod
Copy link
Member

Ok, so this is an issue definitely. I probably need to make dependencies compile-only / shade them as needed.

Adding the transitive = false workaround should work in the meantime.

@boris-petrov
Copy link
Author

Great, thanks, I'm willing to try anything you come up with. :)

@boris-petrov
Copy link
Author

A little development on this. Using:

findbugsPlugins 'com.monits:findbugs-plugin:0.2.0@jar'

Instead of:

findbugsPlugins 'com.monits:findbugs-plugin:0.2.0'

Also fixes the issue. I have no idea what this syntax means, but it might help you figure out the problem. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants