Is there an API for plugins to access command line parameters?

I have a couple custom test plugins (one for cucumber w/ scala/java, and another for jruby rspec, for example), and it would be cool to hook into the command line parameters to specify a specific test to run, rather than running the whole suite. I think gradle 1.11 added the ‘–tests’ command line parameter to specify which junit/testng unit tests should be run; though I haven’t found anything in the docs about how to get at this value. Is this test selection api available to custom plugins as well?

hey matt, you can access the startparameter of a gradle build from the buildscript using


or using Project#getGradle().getStartParameter() in you plugin.

The commandline option ‘–tests’ is passed to ‘Test#setTestNameIncludePattern(String)’ and can be read via 'Test#getFilter()#getIncludePatterns). Have a look at the Gradle DSL reference for the Test task for further information.

Your tasks (not your plugin) can specify a command option via the @Option annotation. You can see an example of it on DependencyInsightReportTask