Gradle application plugin pass commandline args to program using intellij run config (Gradle 4.10)

Viewed 246

I need to pass in a commandline arg ("test") to my application using the gradle application plugin. All works if running as a standard Jar and passing in "-e test" however ive tried passing it in using the Gradle application plugin run task and as an Intellij gradle run config and the args always comes in as empty

I have tried passing command line args in using

gradle run --args '-e test'

This in the Intellij run config

-Dexec.args="test"

And this

-Pargs="test"

The args array is always empty when the program tries to start. How do I pass in "test" as a commandline argument

My entry point

public static void main(String[] args) {
    CommandLine cl = processCommandLineArgs(args);
}
0 Answers
Related