Record Class AssignVersion
- All Implemented Interfaces:
Serializable, org.gradle.api.IsolatedAction<org.gradle.api.Project>
A named record rather than a lambda, because isolated projects constrains what this action may close over and a lambda's captures are invisible: they are whatever happens to be in scope at the point it is written. Here the captured state is the catalogue, so it is declared, reviewed in a diff, and checked by the compiler. In particular this cannot capture the plugin instance, which a lambda calling an instance method silently would.
The other isolated-projects requirement - never touch another project's model - is visible in
execute(Project): it uses the project it is handed and reaches nowhere else. Matching a project to
its package is a lookup in a value computed before any project was evaluated, which is what keeps
per-project versions compatible with isolated projects at all.
IsolatedAction extends Serializable, which is Gradle stating that requirement in
the type system: every component of this record must be serializable, and VersionCatalogue
is.
Public, and not by preference. Gradle 9.0 reconstructs a record by looking up its canonical
constructor as a public member, so a package-private record fails to deserialize with
NoSuchMethodException and every project configuration dies. Later versions look the
constructor up as declared and do not care. The floor decides, so this is public.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAssignVersion(VersionCatalogue catalogue) Creates an instance of aAssignVersionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecataloguerecord component.final booleanIndicates whether some other object is "equal to" this one.voidexecute(org.gradle.api.Project project) final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
AssignVersion
Creates an instance of aAssignVersionrecord class.- Parameters:
catalogue- the value for thecataloguerecord component
-
-
Method Details
-
execute
public void execute(org.gradle.api.Project project) - Specified by:
executein interfaceorg.gradle.api.IsolatedAction<org.gradle.api.Project>
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
catalogue
Returns the value of thecataloguerecord component.- Returns:
- the value of the
cataloguerecord component
-