'Could not set unknown property 'args' for object of type org.gradle.process.internal.DefaultJavaExecAction_Decorated

I have a gradle task defined as:

task deployController {
    mustRunAfter assemble

    doFirst {
       sometasks("${somevar}")
    }
    doLast {
        if (condition) {
            javaexec {
                classpath = someclasspath
                main = "com.somepackage.MainClass"
                workingDir = "${rootProject.buildDir}"
                args = '--add-opens=jdk.crypto.ec/sun.security.ec=ALL-UNNAMED'
            }
        }
    }
}

I need to include args to the javaexec to fix a Reflective Access error, but run into this Could not set unknown property 'args' for object of type org.gradle.process.internal.DefaultJavaExecAction_Decorated. jvmArgs doesn't work either, what is the correct way to specify arguments to a javaexec task?



Solution 1:[1]

Solution:

I used jvmArgs += '--add-opens=jdk.crypto.ec/sun.security.ec=ALL-UNNAMED' instead of args

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John