Is it possible to create a gradle configuration closure from a ConfigObject or Map?

Hi,

I’m using an ssh plugin that requires configuration like the following:

remotes {
    host1 {
        host = 'myFirstHost'
    }
    host2 {
        host = 'mySecondHost'
    }
}

If I retrieve the configuration data from an external source as a Map or Config object, is it possible to turn that into the above configuration?

Thanks!

There is no way to convert automatically, but you can do something like:

remotes {
    host1 {
        host = map["host1"]
    }
    host2 {
        host = map["host2"]
    }
}

Typically there’s a regular object model underlying such configuration, which you could also populate in a more traditional way (without the use of closures).