Package org.gradle.api.tasks

# Annotation Type Optional

@Documented @Retention(RUNTIME) @Target({METHOD,FIELD}) public @interface Optional

Marks a task property as optional. This means that a value does not have to be specified for the property, but any value specified must meet the validation constraints for the property.

This annotation should be attached to the getter method in Java or the property in Groovy. Annotations on setters or just the field in Java are ignored.

This annotation must be combined with one of the following annotations.

- `Input`
- `InputFile`
- `InputDirectory`
- `InputFiles`
- `Nested`
- `OutputFile`
- `OutputFiles`
- `OutputDirectory`
- `OutputDirectories`
- `ServiceReference`

Using `@Optional` alone, without an accompanying input or output annotation, is a validation error. If you want to express that the property should not be an input or output, you should mark it with `Internal` which implies optionality.