Option

Marks a property of a org.gradle.api.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>
  • an enum type or Property<T> of an enum type
  • List<T> of type Double, Integer, Long, String, or an enum type
  • ListProperty<T> and SetProperty<T> of same type as List<T>
  • DirectoryProperty or RegularFileProperty

Note: Multiple @Options 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.

Since

4.6

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun description(): String
The description of this option.
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun option(): String
The option to map to this property.
Link copied to clipboard
abstract fun toString(): String