How to specify defaults for nested modelmap?

(N.A. Today) #1

I am reasonably new to Gradle in general, and very new to the managed class and Rules/RuleSource aspect in particular. I have been experimenting a fair bit to learn more, but have run into a scenario similar to the following:

interface Inner {
    String getString()
    void setString( String string )
interface Outer {
    ModelMap<Inner> getInners()
class MyRules extends RuleSource {
    void outers(ModelMap<Outer> outers) {}
    void defaultInnerString(ModelMap<Outer> outers) {
        // ???
apply plugin: MyRules  

The goal is to create a default Inner if one has not been explicitly configured in the build configuration file. The issue I’m running into is, any attempt to determine whether or not Inner has been defined is met with the following exception:

Build file '/Users/jmash/scratch/build.gradle' line: 18

* What went wrong:
Execution failed for task ':model'.
> Exception thrown while executing model rule: MyRules#defaultInners(ModelMap<Outer>)
   > Attempt to read from a write only view of model element 'outers' of type 'ModelMap<Outer>' given to rule MyRules#defaultInners(ModelMap<Outer>)

This feels like I am overlooking something simple somewhere, but I’ve been through a lot of documentation and Gradle source to try and understand how to achieve this goal, and keep turning up empty.

Is this possible, and if so, how would I go about achieving this?