Is it possible to add support for jvmArgs configuration for Gradle Checkstyle plugin tasks, e.g. checkstyleMain? I’m running into intermittent out-of-memory exceptions when running checkstyle on a pipeline, even with a large maxHeapSize. It would be very useful to, e.g., be able to set the -XX:+HeapDumpOnOutOfMemoryError JVM arg to run heap dumps when this happens for investigation.
I’ve tried setting this in org.gradle.jvmargs in gradle.properties but this doesn’t seem to work. Can’t seem to find other workarounds either.
Having a quick look at the sources, I’d say the only things you can influence are min heap and max heap.
Whether it is possible to add support, for that you should open a feature request on GitHub.
As a work-around you could use the JAVA_TOOL_OPTIONS environment variable, which is usually handled by the JVM itself, unless you use an uncommon JVM that does not support it, and thus can give JVM parameters to any started JVM automatically.
I added export JAVA_TOOL_OPTIONS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/dump/dir" to my local ~/.zprofile, and tried running ./gradlew checkstyleMain with limited maxHeapSize. However it doesn’t look like the checkstyle task picked it up since no heap dumps were produced even though the task did fail with an OutOfMemoryException
Yeah. I’ve cleared the Gradle cache and stopped all daemons, and on starting the checkstyleMain task it does show that the JAVA_TOOL_OPTIONS are picked up. But there’s no dump file in the directory that I set when the exception occurs. I’m using Amazon Coretto 17
I have no idea about Coretto, never used it.
But if it said it picked up the options, then they should be effective.
Maybe you configured something wrong, like mistyped the option name, or the path where the file should be created does not exist.