Class ExtraProperty

java.lang.Object
org.openrewrite.gradle.trait.ExtraProperty
All Implemented Interfaces:
org.openrewrite.trait.Trait<org.openrewrite.java.tree.J>

public class ExtraProperty extends Object implements org.openrewrite.trait.Trait<org.openrewrite.java.tree.J>
Represents an extra property in a Gradle build script where the value is a string literal.

This trait only matches properties where the value can be statically determined as a string literal. Properties with variable references, expressions, or non-string values will not match and the trait will not be created for them.

Handles multiple syntax forms:

  • Variable declarations: def propertyName = 'value' or val propertyName = "value"
  • ext block assignments: ext { propertyName = 'value' }
  • ext field access: ext.propertyName = 'value'
  • ext.set() method: ext.set("propertyName", "value")
  • ext subscript access: ext['propertyName'] = 'value'
  • set() in ext block: ext { set('propertyName', 'value') }
  • Constructor Details

    • ExtraProperty

      public ExtraProperty()
  • Method Details

    • getName

      public String getName()
    • getValue

      public String getValue()
      Gets the string literal value of this property. This method always returns a non-null string because the trait is only created when a string literal value can be extracted from the source code.
      Returns:
      The property's string literal value
    • withValue

      public ExtraProperty withValue(String newValue)
      Update the property value.
      Parameters:
      newValue - The new value to set
      Returns:
      A new ExtraProperty with the updated value, or this if no change was made