Skip to content

Log important JVM errors to Gradle output #71

@mchwedczuk-box-com

Description

@mchwedczuk-box-com

Recently I have been migrating my project to JDK 17.
I used the common workaround for GJF 15.x, that is extra --add-exports directives:

org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

The problem was that I also had org.gradle.jvmargs entry in my ~/.gradle/gradle.properties so my fix was not working (user settings takes precedence over project settings in Gradle).

The behaviour of the plugin was as follows, all files where marked as INVALID. No error message was provided, neither in Gradle --debug output or in Gradle deamon logs.

Interestingly after removing org.gradle.jvmargs from ~/.gradle/gradle.properties the plugin cached the INVALID statuses in fileStates.txt file and the problem persisted until I executed ./gradlew clean.

Looking at the source code of the plugin I noticed that in few places you are catching Throwable or Error. This is a bad practice. If you want to catch JVM errors like ClassDefNotFound (like I get with the missing exports) it would be good to at least log those errors to Gradle output.

One example of such place:

Please make the plugin more debuggable by not swallowing important JVM errors but instead by logging them as WARNings to Gradle output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions