Hello Glen,
sorry for the late reply. You can pass properties from the commandLine to your run task by using a bit groovy:
You can dynamically add args to the run task:
----------------
run{
    if(project.hasProperty("appProp")){
        args appProp
    }
}
----------------

this checks if a property named "appProp" is defined. If true, it passes the property to the arg method of the run task.
Now you can run your app via gradle from the commandline:

----------
gradle run -PappProp=test
----------

regards
René

7. März 2012 04:04
Thanks René,

That lets me pass arguments by hard coding them into my build.gradle but I was wanting to pass args from the gradle command line. For example something like:

gradle run arg1 arg2 ...

Regards,

Glen




6. März 2012 09:09
Hello Glen,
The run task is of type JavaExec. As you can see in the DSL Documentation of JavaExec ( http://gradle.org/docs/current/dsl/org.gradle.api.tasks.JavaExec.html#org.gradle.api.tasks.JavaExec:args ), you can pass parameters to the task using "args":

run{
    args '-i'
}

regards,
René

6. März 2012 01:54
One of the tasks the gradle application plugin creates is called 'run'.  This works great but how do I pass command line arguments to the application it is running?  Gradle seems to want to interpret anything I pass on the command line.

Regards,

 Glen


Reply via email to