Command line arguments to application?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Command line arguments to application?

ewhauser
Is there any way to pass command line arguments when using the application plugin?

gradle :myapp:run -argsToHere

Args are parsed by gradle itself, so it doesn't seem you can pass them to the app.
Reply | Threaded
Open this post in threaded view
|

Re: Command line arguments to application?

Adam Murdoch

On 19/03/2011, at 12:35 PM, ewhauser wrote:

Is there any way to pass command line arguments when using the application
plugin?

gradle :myapp:run -argsToHere

You can't do this yet, though this is something we want to allow in the future.

In the meantime, you could use a project property:

gradle :myapp:run -Pargs="a b c"

and in your build script, you could do something like:

run {
   if ( project.hasProperty('args') ) {
       args project.args.split('\\s+')
   }
}


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
Co-Founder and VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com