Groovy upgrade crashing due to heap size

When upgrading moqui with the newer groovy version, I’m getting a heap crash [2]. It seems that the root cause might be coming from GROOVY-12318. The suspicison is that under the default heap size of 512MB the parser cache cleanup happens too late.

The solution is either A) upgrade groovy, or B) to add to framework/build.gradle the below snippet [1]. Upgrading groovy causes other issues, so the faster workaround for now is to apply below snippet [1].

FYI @jonesde @michael

[1]

tasks.withType(GroovyCompile).configureEach {
    groovyOptions.forkOptions.memoryMaximumSize = '1g'
}

[2]

❯ ./gradlew build

> Task :framework:compileStartJava
Note: /home/taher/Desktop/moqui-framework/framework/src/start/java/MoquiStart.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :framework:compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :framework:compileGroovy FAILED

[Incubating] Problems report is available at: file:///home/taher/Desktop/moqui-framework/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':framework:compileGroovy'.
> Java heap space

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 1m
3 actionable tasks: 3 executed