@Retention(RUNTIME)
@Target({METHOD,FIELD})
@Inherited
public @interface Option
Marks a property of a Task
as being configurable from the command-line.
This annotation should be attached to a field or a setter method. When attached to a field, option()
will use the name of the field by default. When attached to a method, option()
must be specified.
An option may have one of the following types:
boolean
, Boolean
, or Property<Boolean>
Double
or Property<Double>
Integer
or Property<Integer>
Long
or Property<Long>
String
or Property<String>
enum
type or Property<T>
of an enum typeList<T>
of type Double
, Integer
, Long
, String
, or an enum
typeListProperty<T>
and SetProperty<T>
of same type as List<T>
DirectoryProperty
or RegularFileProperty
Note: Multiple @Option
s with the same names are disallowed on different methods/fields.
Methods with the same signature (i.e. the same name, return type, and parameter types) are allowed to use
equal or unequal option names.
When the option names are equal, the description and method linked to the option will be the one in the base class (if present), followed by super-classes, and finally interfaces, in an unspecified order.
When the option names are unequal, the order described above is used when setting the option's value. If the base class has an option with the name "foo" and an interface has an option with the name "bar", the option "foo" will have precedence over the option "bar" and setting both will result in the value of "foo".
Depending on this behavior is discouraged. It is only in place to allow legacy migration to interface options.
Modifier and Type | Required Element | Description |
---|---|---|
java.lang.String |
description |
The description of this option.
|
Modifier and Type | Optional Element | Description |
---|---|---|
java.lang.String |
option |
The option to map to this property.
|