Hi All, I want to run a simple script that expects a command line argument to be passed from Gradle. But I only want to pass that argument when I actually run the script. Not every time I run anything else in Gradle.
Consider Exec task.
task runPython(type: Exec) {
workingDir 'scripts'
commandLine 'python', 'my_script.py', '--target', project.target
Since my python script expects –target SomeTarget argument, I want to pass it to Gradle using -P target=SomeName
But now it seems I have to pass that -P target=SomeName to any other Gradle task. Otherwise it fails at configuration phase. Even though it doesn’t even make sense for other tasks.
And moving it to execution phase fails with execCommand == null. And I guess I know why, due to way Gradle works with pre-building the execution graph.
task runPython(type: Exec) doLast {
workingDir 'scripts'
commandLine 'python', 'my_script.py', '--target', project.target
Does anyone have idea how do I do this without passing this parameter over?
Thank You!