7
https://stackoverflow.com/a/23689696/1757491传递命令行参数到运行任务
我开始使用一些信息从上面的回答所提出的解决方案: 应用程序插件方法
(的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()
}
命令Line:
gradle run -Dexec.args="arg1 arg2 arg3"
it wor ks对于它的预期目的很好,但似乎有副作用。这是有道理的命令行参数运行通过,但我必须要通过他们在例如每一项任务:
gradle tasks -Dexec.args="arg1 arg2 arg3"
如果我离开了
-Dexec.args="arg1 arg2 arg3"
我得到
"build failed with an exception"
Where:path\build.gradle line:18 which if where my run{ } is.