Unable to expand JAVA_OPTS post gradle-7.2

build.gradle:

ext.getJvmArgs = { jmxPort, jdwpPort, initialRamPercentage = 50.0, maxRamPercentage = 70.0 ->
    return ["-XX:InitialRAMPercentage=$initialRamPercentage",
            "-XX:MaxRAMPercentage=$maxRamPercentage",
            "-XX:+UseStringDeduplication",
            // Force G1GC as the GC collector. In a container environment, GC is selected by docker based on CPU and Memory.
            "-XX:+UseG1GC",
            "-Duser.timezone=\"UTC\"",
            "-Dcom.sun.management.jmxremote",
            "-Dcom.sun.management.jmxremote.authenticate=false",
            "-Dcom.sun.management.jmxremote.ssl=false",
            "-Dcom.sun.management.jmxremote.local.only=false",
            "-Dcom.sun.management.jmxremote.port=$jmxPort",
            "-Dcom.sun.management.jmxremote.rmi.port=$jmxPort",
            "-Djava.rmi.server.hostname=127.0.0.1",
            "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$jdwpPort"]
}

subproject.gradle:

task task_name(type: CreateStartScripts) {
    mainClass = "com.a.b.c.d.e"
    applicationName = "sample_name"
    int jmxPort = 2609
    int jdwpPort = 2611
    float initialRamPercentage = 30.0
    float maxRamPercentage = 60.0
    defaultJvmOpts = project.getJvmArgs(jmxPort, jdwpPort, initialRamPercentage, maxRamPercentage) + ['-XX:ErrorFile=/vdt/hs_err_pid%p.log']
    outputDir = new File(project.buildDir, 'scripts')
    classpath = jar.outputs.files + configurations.runtimeClasspath
}

Error:

Forwarding from 127.0.0.1:2609 -> 2609
Forwarding from [::1]:2609 -> 2609
Handling connection for 2609
E0705 15:15:18.230959   13229 portforward.go:406] an error occurred forwarding 2609 -> 2609: error forwarding port 2609 to pod 51482420046fe7d4c65e09edfb0dacf3185d9f235f8155330a2ae711140dbf2e, uid : failed to execute portforward in network namespace "/var/run/netns/cni-52a11e9e-af7a-0cc9-dc6e-19dd6309cafd": failed to connect to localhost:2609 inside namespace "51482420046fe7d4c65e09edfb0dacf3185d9f235f8155330a2ae711140dbf2e", IPv4: dial tcp4 127.0.0.1:2609: connect: connection refused IPv6 dial tcp6: address localhost: no suitable address found 
E0705 15:15:18.231266   13229 portforward.go:234] lost connection to pod
Handling connection for 2609
E0705 15:15:18.232054   13229 portforward.go:346] error creating error stream for port 2609 -> 2609: EOF