https://stackoverflow.com/a/23689696/1757491
I started using some info from the proposed solution from the above answer: Application Plugin Approach
(build.gradle)
apply plugin: 'application'
mainClassName = "com.mycompany.MyMain"
run {
/* Need to split the space-delimited value in the exec.args */
args System.getProperty("exec.args").split()
}
Command Line:
gradle run -Dexec.args="arg1 arg2 arg3"
it works great for its intended purpose but seems to have a side effect. It makes sense to pass in the command line arguments for run but I have to pass them in for every task for example:
gradle tasks -Dexec.args="arg1 arg2 arg3"
If I leave out the
-Dexec.args="arg1 arg2 arg3"
I get
"build failed with an exception"
Where:path\build.gradle line:18 which if where my run{ } is.