On 23/03/2011, at 9:54 AM, phil swenson wrote: > If I want to pass in params to a gradle task, is my only option using > -Dname=value? > > It's quite ugly: gradle createModule –Dmodule=<moduleName> > -Dplugin=<pluginName> > > Just curious > >
You can use -D, and -P. -P is probably the better option at this stage. Depending on what you want to do exactly, another option is to use a task rule, so that the parameter is encoded in the task name. For example, you might have a rule which maps 'start<ServerName>' to a task which starts the specified server. So, you'd run 'gradle startTest1' or 'gradle startLocalTest' or whatever. We do want to add something to allow you to pass arbitrary configuration from the command-line. For example, there might be a general capability where you can do something like 'gradle createModule module=<n> plugin=<p>' or perhaps 'gradle createModule --module <n> --plugin <p>' and Gradle will automatically set the module and plugin properties of the createModule task without you having to do anything in the build script. Or perhaps the task might need to explicitly declare which properties should be configurable from outside the script. This might be nice, as then we could show this in the output of a 'gradle help createModule' report, or on the GUI. And Gradle could do validation, so that if a property must be configured from the command-line, Gradle can give the user a nice error message when the user hasn't provided a value. Or can prompt for a value, or whatever. We'd probably also add a similar mechanism for configuring project properties, too, including those added by plugins. Regardless, the goal is that the experience will be much better for those who use the build (including those who use a GUI) and quite a bit simpler for the build author. -- Adam Murdoch Gradle Developer http://www.gradle.org Co-Founder and VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting http://www.gradleware.com
