For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

ComponentType

Deprecated

The Gradle software model is deprecated and will be removed in Gradle 10. Use the new component model (e.g. cpp-application, cpp-library, swift-application, swift-library, xctest) instead.

Declares a custom org.gradle.platform.base.ComponentSpec type. The following example demonstrates how to register a custom component type using a plugin with a ComponentType annotation. Furthermore the plugin creates an instance of SampleComponent named 'sampleComponent'.

interface SampleComponent extends ComponentSpec {}
class DefaultSampleComponent extends BaseComponentSpec implements SampleComponent {}

apply plugin: MySamplePlugin

class MySamplePlugin extends RuleSource {
    @ComponentType
    void register(TypeBuilder<SampleComponent> builder) {
        builder.defaultImplementation(DefaultSampleComponent)
    }

    @Mutate
    void createSampleLibraryComponents(ModelMap<SampleComponent> componentSpecs) {
        componentSpecs.create("sampleComponent")
    }
}

Since

2.2

Functions

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