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

Spotbugs 2.0 breaks if Guava is on the plugin classpath #166

Closed
isker opened this issue Oct 10, 2019 · 6 comments
Closed

Spotbugs 2.0 breaks if Guava is on the plugin classpath #166

isker opened this issue Oct 10, 2019 · 6 comments

Comments

@isker
Copy link

isker commented Oct 10, 2019

If spotbugs-gradle-plugin 2.0 is used in addition to any other plugin that uses an older Guava on the classpath, the build can fail as this plugin has somehow forced Gradle's Guava off of Gradle's classpath.

I have a reproducer at https:/isker/spotbugs-guava-failure. See build.gradle for all that's needed to trigger this failure.

@oehme notes that this is due to the usage of many internal worker APIs and ClassLoader manipulation in this plugin, for example:

final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
final List<String> args = spec.getArguments();
String[] strArray = args.toArray(new String[0]);
Thread.currentThread().setContextClassLoader(FindBugs2.class.getClassLoader());
FindBugs2 findBugs2 = new FindBugs2();
TextUICommandLine commandLine = new TextUICommandLine();
FindBugs.processCommandLine(commandLine, strArray, findBugs2);
findBugs2.execute();
return createSpotbugsResult(findBugs2);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}

import org.gradle.process.internal.JavaExecHandleBuilder;
import org.gradle.process.internal.worker.SingleRequestWorkerProcessBuilder;
import org.gradle.process.internal.worker.WorkerProcessFactory;

This is a blocker to upgrading Gradle to 6.0 in any project that uses spotbugs and an older Guava on the buildscript classpath, as there is a 5.x deprecation warning that is fixed only in version 2.0 of this plugin on this line:

A potential workaround is to force resolution to a higher version of Guava (ideally the same one used in Gradle itself) on the buildscript classpath.

@oehme
Copy link

oehme commented Oct 10, 2019

Instead of working around, the spotbugs plugin should either

  • use the public worker API or
  • use javaExec

Whichever fits its use case better. Please don't use internals like this.

@KengoTODA
Copy link
Member

This classpath issue is reported continuously, such as #119, #120, #128 and #147
And the ideal solution is also known as @oehme mentioned.

What we need is a contribution to realize. This is a volunteer project, have a try if you have time!

@DPUkyle
Copy link
Contributor

DPUkyle commented Nov 4, 2019

IIRC from #57 and #100 , javaExec is the only practical option; that is because the spotbugs tool itself carries stateful information from static initialization that persists in a dormant worker API daemon.

Worker API would be nice but unless the statefulness mentioned by @Vampire in #100 is fixed then Worker API is probably not an option.

@Vampire
Copy link

Vampire commented Nov 4, 2019

I didn't read the whole history here, just got here because of the mention. As I said in #100 already, I think a combination of worker API with javaExec should be used. That way you get parallelism by usage of the worker API and needed isolation by usage of javaExec.

@KengoTODA
Copy link
Member

Please refer #180 and try the new implementation, it should work. If it still faces problem, please share it at here.

@KengoTODA
Copy link
Member

I'll close this inactive issue. If you could reproduce this with the latest release, please feel free to reopen.

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

No branches or pull requests

5 participants