This message was deleted.
# community-support
s
This message was deleted.
s
And of course trying to set the field via the
build.gradle.kts
resulted in all sorts of complaints.
j
Extensions are not properties
There are samples about nesting extensions in the Gradle docs (I am from mobile I cannot link them now)
s
Thanks -- that was helpful!
A followup would be -- is there a way to support a set of some extension object -- e.g.
Copy code
interface OuterExtension {
  val setOfSetElement: Set<SetElementExtension>
}

interface SetElementExtension {
  val someBool = Property<Boolean>
  val someString = Property<String>
}
I'm not quite sure what the
build.gradle.kts
syntax would look like to set this in a natural way since I'd need to create an instance somehow to add via
add
Copy code
outerExtension {
  setOfSetElement {
    add(???)
  }
}
e
just add a regular function,
Copy code
interface Outer Extension {
  fun setOfSetElement(action: Action<SetOfSetElement>) {
    action.execute(setOfSetElement)
  }
}
s
thank you -- I ended up finding examples doing just that and it worked great...
r
@Sean Chen Can you provide a final implementation of the nested extension with lazy evaluation? I am struggling with the same problem
I ended doing:
Copy code
abstract class TestExtensions {
    abstract val enableLocking: Property<Boolean>
    abstract val resolveConsistently: Property<Boolean>

    @get:Nested
    abstract val coverage: JacocoCoverageExtension
    fun coverage(action: Action<JacocoCoverageExtension>) {
        action.execute(coverage)
    }

    init {
        enableLocking.convention(true)
        resolveConsistently.convention(true)
    }
}
I am not sure if Nested does something but it works
s
Yeah -- that was primarily it... I'm not 100% sure I'm using lazy eval for the nested elements, but I think it boiled down to the extension just being a normal member, not wrapped as Propert<...> etc.