Record Class ApplyProjectPlugin

java.lang.Object
java.lang.Record
io.github.joke.conventionalversion.ApplyProjectPlugin
All Implemented Interfaces:
Serializable, org.gradle.api.IsolatedAction<org.gradle.api.Project>

public record ApplyProjectPlugin() extends Record implements org.gradle.api.IsolatedAction<org.gradle.api.Project>
How settings mode reaches every project: by applying ProjectVersionPlugin to each of them.

Settings mode calculates nothing of its own. Making it project mode applied everywhere is what makes the level a build chooses unable to change the answer it gets - there is one code path, not two kept in agreement.

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. This closes over nothing at all - not even the catalogue, which each project obtains for itself from a build service - so there is nothing to review and nothing to serialize. In particular it cannot capture a plugin instance, which a lambda calling an instance method silently would.

IsolatedAction extends Serializable, which is Gradle stating that requirement in the type system.

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

    Constructors
    Constructor
    Description
    Creates an instance of a ApplyProjectPlugin record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    void
    execute(org.gradle.api.Project project)
     
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ApplyProjectPlugin

      public ApplyProjectPlugin()
      Creates an instance of a ApplyProjectPlugin record class.
  • Method Details

    • execute

      public void execute(org.gradle.api.Project project)
      Specified by:
      execute in interface org.gradle.api.IsolatedAction<org.gradle.api.Project>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.