# ManagedType

@Incubating
@Documented
@Retention(value = RetentionPolicy.RUNTIME)
annotation class ManagedType(source)

Marks Gradle-provided types that can be instantiated via the managed object infrastructure.

Types annotated with this annotation will be automatically instantiated by Gradle when constructing managed objects. This annotation is present only on Gradle-native types * and does not need to be added to custom user-instantiated types. To create a managed property, declare an abstract getter method for the given type. For the managed property to be created properly, the object containing it must be instantiated using the newInstance or as a managed org.gradle.api.tasks.Nested property. The example below creates a `ConfigurableFileCollection` and `RegularFileProperty` automatically when the `MyObject` instance is instantiated by Gradle:

    interface NestedExample {
        Property<String> getExampleMessage();
    }

    interface MyObject {
        ConfigurableFileCollection getFiles();

        RegularFileProperty getProperty();

        @Nested
        NestedExample getNested();
    }

    def instance = objects.newInstance(MyObject)
    instance.files.from(file("foo.txt"))
    instance.property = file("bar.txt")
    instance.nested.exampleMessage = "Hello, World!"

Content copied to clipboard

#### Since

9.0.0

#### See also

Managed types reference

## Functions

annotationType
Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
equals
Link copied to clipboard
abstract fun equals(p: Any): Boolean
hashCode
Link copied to clipboard
abstract fun hashCode(): Int
toString
Link copied to clipboard
abstract fun toString(): String