Search code examples
gradleintellij-ideagithub-actionsgradle-pluginintellij-plugin

compileKotlin step of Intellij plugin build fails on Java heap space in Github Actions


I have an Intellij plugin I built using the template https://github.com/JetBrains/gradle-intellij-plugin

My action:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Setup Java
        uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: 11
          cache: gradle

      - name: Plugin
        env:
          CI_BUILD_PLUGIN: true
          DEFAULT_JVM_OPTS: "-Xmx5g -Xms5g"
          GRADLE_OPTS: "-Dkotlin.daemon.jvm.options=-Xmx5G"
        run: |
          ./gradlew check
          ./gradlew runPluginVerifier

When running ./gradlew check in Github Actions, I'm getting Java heap space error:

Execution failed for task ':compileKotlin'.
See the complete report at file:///home/runner/work/xxx/plugins/intellij-platform/build/reports/configuration-cache/avgk7hbsu56pccc278todq8le/5a6oh43i8gcje908b7bopoqxi/configuration-cache-report.html
7 actionable tasks: 7 executed
> Could not resolve all files for configuration ':detachedConfiguration1'.
   > Failed to transform app.jar to match attributes {artifactType=classpath-entry-snapshot, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for ClasspathEntrySnapshotTransform: /home/runner/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.3.1/2a2986db4e11c3d378b4d1c8b9fd040cd6d99802/ideaIC-2022.3.1/lib/app.jar.
         > Java heap space

As Github runner has 7GB memory, I'm doubting very much its reaching that limit. Moreover, running locally doesn't incur such memory usage.

I tried to set JVM heap as you can see in the action yaml, but it didn't have any effect.

This heap error is only reproduced for build with platform version 2022.3.1+ , I'm assuming they just go over the default heap limit.

Is there any configuration I'm missing?


Solution

  • This seems to be a somewhat known problem, starting with org.jetbrains.kotlin.jvm version 1.8.20.

    You should be able to up the heap in gradle.properties, like so: org.gradle.jvmargs=-Xmx4g -Xms1g.

    Alternatively, you can disable incremental compilation like so: kotlin.incremental.useClasspathSnapshot=false

    Either one of the two modifications should fix the problem.