# How to get --tests command params in plugin?

**URL:** <https://discuss.gradle.org/t/how-to-get-tests-command-params-in-plugin/21256>\
**Category:** Plugin Portal\
**Created:** [January 21, 2017, 12:50pm UTC](https://discuss.gradle.org/t/how-to-get-tests-command-params-in-plugin/21256 "2017-01-21T12:50:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blindpirate](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/blindpirate/32/6414_2.png) [@blindpirate](https://discuss.gradle.org/u/blindpirate)\
**Post date:** [January 21, 2017, 12:50pm UTC](https://discuss.gradle.org/t/how-to-get-tests-command-params-in-plugin/21256/1 "2017-01-21T12:50:41Z")

</div>

I’m writing a plugin and want to get some command line params starting with “–”, e.g, getting ‘\*SomeTest’ from ‘gradle --tests \*SomeTest’ command.

How can I achieve this goal?

Please help me

---

<div class="post-metadata">

**Author:** ![Chris\_Dore](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/chris_dore/32/7592_2.png) [@Chris\_Dore](https://discuss.gradle.org/u/Chris_Dore)\
**Post date:** [January 21, 2017, 7:22pm UTC](https://discuss.gradle.org/t/how-to-get-tests-command-params-in-plugin/21256/2 "2017-01-21T19:22:46Z")

</div>

Support for custom command line arguments is not a public feature of the Gradle API. There exists an internal annotation named [Option](https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/java/org/gradle/api/internal/tasks/options/Option.java) that _could_ be used (see Gradle source for usage examples).

However, since it is an **internal** API it is subject to change at any point and may cause you issues when changing Gradle versions.  
Alternatively, you can use `-Pproperty=value` and reference that property in various ways. There is some information about properties in the [userguide](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_properties_and_system_properties) and [DSL reference](https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N1433B)/[javadoc](https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html). One of the nicer things about properties is that they can be set in more than one way (commandline, project’s gradle.properties, user’s gradle.properties), making them a bit more flexible.

---

<div class="post-metadata">

**Author:** ![Chris\_Dore](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/chris_dore/32/7592_2.png) [@Chris\_Dore](https://discuss.gradle.org/u/Chris_Dore)\
**Post date:** [January 21, 2017, 8:12pm UTC](https://discuss.gradle.org/t/how-to-get-tests-command-params-in-plugin/21256/3 "2017-01-21T20:12:42Z")

</div>

See also, [this conversation](https://discuss.gradle.org/t/command-line-options-for-tasks/9686).

---

<div class="post-metadata">

**Author:** ![blindpirate](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/blindpirate/32/6414_2.png) [@blindpirate](https://discuss.gradle.org/u/blindpirate)\
**Post date:** [January 21, 2017, 10:12pm UTC](https://discuss.gradle.org/t/how-to-get-tests-command-params-in-plugin/21256/4 "2017-01-21T22:12:07Z")

</div>

Thanks a lot!

You save my day!

---

<div class="post-metadata">

**Author:** ![blindpirate](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/blindpirate/32/6414_2.png) [@blindpirate](https://discuss.gradle.org/u/blindpirate)\
**Post date:** [January 22, 2017, 1:08pm UTC](https://discuss.gradle.org/t/how-to-get-tests-command-params-in-plugin/21256/5 "2017-01-22T13:08:26Z")

</div>

Hi Chis, I have encountered a new problem. When I start a build with `BuildLauncher` and ‘–tests’ arguments, I got the follow error:

```
Unknown command-line option '--tests'.
Either it is not a valid build option or it is not supported in the target Gradle version.
Not all of the Gradle command line options are supported build arguments.
Examples of supported build arguments: '--info', '-u', '-p'.
Examples of unsupported build options: '--daemon', '-?', '-v'.
Please find more information in the javadoc for the BuildLauncher class.

```

How can I turn on `allowUnknownOptions` in build started by `BuildLauncher` ?

Thank you very much.
