api / org.gradle.api.attributes / AttributesSchema / attribute

attribute

abstract fun <T : Any> attribute(attribute: Attribute<T>): AttributeMatchingStrategy<T>

Declares a new attribute in the schema and configures it with the default strategy. If the attribute was already declared it will simply return the existing strategy.

Parameters

attribute - the attribute to declare in the schema

- the concrete type of the attribute

Return
the matching strategy for this attribute

abstract fun <T : Any> attribute(attribute: Attribute<T>, configureAction: Action<in AttributeMatchingStrategy<T>>): AttributeMatchingStrategy<T>

Configures the matching strategy for an attribute. The first call to this method for a specific attribute will create a new matching strategy, whereas subsequent calls will configure the existing one.

Parameters

attribute - the attribute for which to configure the matching strategy

configureAction - the strategy configuration

- the concrete type of the attribute

Return
the configured strategy