Spotbugsplugin with gradle > 5.0 fails (GC overhead limit exceeded)

The change in memory settings with gradle 5.0 means that spotbugs will no longer work on large projects.

In the spotbugsplugin GitHub project I created a process a long time ago, unfortunately without a solution. https://github.com/spotbugs/spotbugs-gradle-plugin/issues/85

Can I change anything at the Gradle settings that it will work again?

I have a build scan from a build. https://scans.gradle.com/s/vciemyka5mvk6

Yes, as you mentioned, the default settings have changed in 5.0.

If you need help overriding these defaults, check out the section on configuring JVM memory in the docs.

If these changes don’t fix it, you may be running into an issue with the SpotBugs plugin like the one described here for another plugin.

Please let us know if it’s not any of those things.

I made the following parameters in the gradle.properties and started the Spotbugs task via the gradlewrapper

gradle.properties
org.gradle.daemon=false
org.gradle.caching=true
org.gradle.logging.level=debug
org.gradle.warning.mode=all
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xms512m -Xmx4g

Clipping logfile:
log.zip (2.4 KB)

You need to configure the memory for Spotbugs, not for the Gradle daemon. You can do this by adding extra JVM args to spotbugs.jvmArgs

Also, do not disable the Gradle daemon. That makes your builds unnecessarily slow.

Thanks, I have now adjusted it and gradually increased the memory. Unfortunately, this did not lead to success.

spotbugs {
toolVersion = ‘3.1.10’
jvmArgs = [‘-Xmx12g’, ‘-XX:MaxPermSize=256m’, ‘-XX:+HeapDumpOnOutOfMemoryError’]
}

I created another scan: Build Scan® | Gradle Cloud Services

I hope you can take the log a hint.

The scan you sent just shows that you tried to give it too much memory, so the JVM just crashed.

Also I had another look and spotbugs has a separate setting for spotbugs.maxHeapSize independent of the spotbugs.jvmArgs, so you’ll want to adjust that instead.

1 Like

With the switch I have already tried it, but then get the following error:´
spotbugs.maxHeapSize=‘2g’
spotbugs.toolVersion =‘3.1.10’

15:41:26.772 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:41:26.772 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:41:26.772 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Where:
15:41:26.772 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Build file ‘C:\Entwicklung\workspaceCSS\ekit\build.gradle’ line: 41
15:41:26.773 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:41:26.773 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
15:41:26.773 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred evaluating root project ‘ekit’.
15:41:26.773 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not set unknown property ‘maxHeapSize’ for object of type com.github
.spotbugs.SpotBugsExtension.

I’ve managed it with the help of the QualityPlugin. Failure Spotbugs with gradle 5.0 - GC overhead limit exceeded · Issue #12 · xvik/gradle-quality-plugin · GitHub