gradle
8.4

# Option

@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = [ElementType.METHOD, ElementType.FIELD])
@Inherited
annotation class Option(source)

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`
- `Property<Boolean>`
- an `enum` type
- `Property<T>` of an enum type
- `String`
- `Property<String>`
- `List<T>` of an `enum` type
- `List<String>`

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.

## Functions

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