interface ModelElement : Named
Represents an element in a model. Elements are arranged in a hierarchy. |
|
interface ModelMap<T : Any> : MutableIterable<T>, ModelElement
Model backed map like structure allowing adding of items where instantiation is managed. org.gradle.model.Managed types may declare model map properties. Model maps can only contain managed types. |
|
interface ModelSet<T : Any> : MutableSet<T>, ModelElement
A set of managed model objects. org.gradle.model.Managed types may declare managed set properties. Managed sets can only contain managed types. Managed set objects cannot be mutated via the mutative methods of the java.util.Set interface (e.g. |
|
open class RuleSource
A marker type for a class that is a collection of rules. A rule source is not used like a regular Java object. It is a stateless container of methods and possibly constants. Please consult the “Rule based model configuration” chapter of the Gradle User Guide for general information about “rules”. Rule methodsEach method that is annotated with one of the following is considered a rule:
Each annotation specifies the type of the rule, which affects when it will be executed. The following constraints apply to all rule methods:
See Model for information on the significance of the return type of a Model method. Subjects and inputsMethod rules declare the subject and any inputs as parameters to the method. With the exception of Model methods, the subject of the rule is the, required, first parameter and all subsequent parameters are inputs. For a non-void Model method, the subject (i.e. model element being created) is the return object. For a void Model method, the subject is the first method parameter. The Path annotation can be placed on any parameter (except the subject of Model rules) to indicate the model element to bind to. If there is no Path annotation, a “by-type” binding will be attempted. The binding scope is determined by how the rule source is applied. General class constraintsAlong with the constraints on individual rule methods by their associated annotation, the following are general constraints of rule source implementations:
|
class Defaults
Denotes that the RuleSource method rule carrying this annotation initializes the rule subject with default values. Default rules execute first for a given subject, just after the subject has been created but before Model rules and Mutate rules. The first parameter of the rule is the rule subject, which is mutable for the duration of the rule. Please see RuleSource for more information on method rules. |
|
class Each
Signals that a RuleSource rule should be applied to all matching descendant elements of the scope instead of the scope itself. |
|
class Finalize
Denotes that the RuleSource method rule carrying this annotation finalizes the rule subject. Finalize rules execute after Mutate rules, but before Validate rules. The first parameter of the rule is the rule subject, which is mutable for the duration of the rule. Please see RuleSource for more information on method rules. |
|
class Managed
A managed type is transparent to the model space, and enforces immutability at the appropriate times in the object's lifecycle. Gradle generates implementations for managed types. As such, managed types are declared either as interfaces or abstract classes. The generated implementation integrates with the model space mechanisms, and manages mutability. Managed types are mostly behaviour-less, as they are data. Instances of managed types should effectively be considered value objects. PropertiesManaged types declare their structure as properties, via getter and setter methods. Getter and setter methods are expected to conform to the well-known Java Bean naming conventions. A read/write “name” property would be expressed via the following methods:
A getter and setter must be declared for each property that is not of a managed type or of ModelSet. For properties of managed types or of ModelSet the getter is mandatory and the setter is optional. If no setter is provided the property is considered inherent and defaults to an "empty" instance of the type. In addition to the traditional getter method, properties of type Supported property types
The following JDK types are allowed:
All primitive types and Enum types are also allowed. Properties that are themselves of a managed type are also supported. Currently, the only collection types that are supported are ModelSet and ModelMap, as well as java.util.Set or java.util.List of org.gradle.model.internal.manage.schema.extract.ScalarTypes, where scalar types is either one of the supported immutable JDK types above or an enumeration. Properties of any other type must have their getter annotated with Unmanaged. An unmanaged property is not transparent to the model infrastructure and is guaranteed to be immutable when realized. Named types Managed types may implement/extend the org.gradle.api.Named interface. Any managed type implementing this interface will have its The ModelMap type requires that its elements are org.gradle.api.Named. InheritanceManaged types can be arranged into an inheritance hierarchy. Every type in the hierarchy must conform to the constraints of managed types. Calculated read-only propertiesManaged types can contain getter methods that return calculated values, based on other properties. For example, a “name” property may return the concatenation of a “firstName” and “lastName” property. When using Java 8 or later, such properties can be implemented as interface default methods. Alternatively, the managed type can be implemented as an abstract class with the calculated property implemented as a non-abstract getter method. In both cases, the implementation of the calculated property getter may not call any setter method. Abstract classes A managed type can be implemented as an abstract class. All property getters and setters must be declared Please see Model for information on creating model elements of managed types. |
|
class Model
Denotes that the RuleSource method rule carrying this annotation creates a new top level element in the model space. The method must advertise a name and type for the model element. The name is defined either by the name of the method, or the If the element is to be of a managed type, the method must return It is an error for a If the element is to be of a non-managed type, the method must return the newly created instance. All parameters are considered inputs. Please see RuleSource for more information on method rules. |
|
class Mutate
Denotes that the RuleSource method rule carrying this annotation mutates the rule subject. Mutate rules execute after Defaults rules, but before Finalize rules. The first parameter of the rule is the rule subject, which is mutable for the duration of the rule. Please see RuleSource for more information on method rules. |
|
class Path
Specifies a model path on a parameter |
|
class RuleInput
Attached to the getter for a property on a RuleSource to denote that the property defines an implicit input for all rules defined by the rule source. |
|
class RuleTarget
Attached to the getter for a property on a RuleSource to denote that the property defines the target for the rule source. |
|
class Rules
Denotes that the RuleSource method rule carrying this annotation defines additional rules based on its inputs. |
|
class Unmanaged
Indicates that a property of a managed model element is explicitly of an unmanaged type. This annotation must be present on the getter of the property for the unmanaged type. If the annotation is not present for a property that is not a managed type, a fatal error will occur. |
|
class Validate
Denotes that the RuleSource method rule carrying this annotation validates the rule subject. Validate rules execute after Finalize rules, but before rule subject is used as an input. The first parameter of the rule is the rule subject, which is immutable. Please see RuleSource for more information on method rules. |
open class ConfigurationCycleException : GradleException
Thrown when a cycle is encountered while configuring a model element. |
|
open class InvalidModelRuleDeclarationException : GradleException
Thrown when a model rule, or source of model rules, is declared in an invalid way. |
|
open class InvalidModelRuleException : GradleException
Thrown when there is a problem with the usage of a model rule. This exception is different to InvalidModelRuleDeclarationException in that it signifies a problem with using a model rule in a particular context, whereas This exception should always have cause, that provides information about the actual problem. |
|
open class ModelRuleBindingException : GradleException
Thrown when there is a problem binding the model element references of a model rule. Should always be thrown as the cause of a org.gradle.model.InvalidModelRuleException. |
|
open class ModelViewClosedException : ReadOnlyModelViewException
Thrown when at attempt is made to mutate a subject of a rule after the rule has completed. This can potentially happen when a reference to the subject is retained during a rule and then used afterwards, Such as when an anonymous inner class or closure “closes over” the subject. |
|
open class ReadOnlyModelViewException : GradleException
Thrown when an attempt is made to change the value of a model element that is not writable at the time. |
|
open class WriteOnlyModelViewException : GradleException
Thrown when an attempt is made to read the value of a model element that is not readable at the time. |