How to increase Gradle heap space for Task Runner builds in Foundry?

I’m using Task Runner to build my Java transform repository in Foundry, but Gradle is running out of heap space during the build. I know for a fact it’s my protobuf generation that’s causing the heap exhaustion. I have a .proto file that has some very large enumerations in it, but I can’t change the file because it’s controlled by an external application that I’m interfacing with. I can get my Java transform to build locally by increasing Xmx in gradle.properties, but Task Runner ignores the argument.

AIP Assist recommended adding the following to my build.grade, but my build still fails in Foundry:
tasks.withType(JavaCompile) {

 options.forkOptions.jvmArgs = \['-Xmx4g'\] 

}

The documentation doesn’t specify how to configure JVM heap space for Gradle when using Task Runner. Are there any settings or workarounds to increase the heap space for Gradle builds in this environment?

My fallback is to use protobuf compiler to generate the Java class and check it into the repo, but I really prefer to have gradle autogenerate it.