Section 13.5.4, “List and map literals”, tries to show examples of using both list and map literals. It seems to show examples of list literals, but the map literal example isn’t really a “literal” as I would expect.
For the "Map Literal’ section, it just shows this:
But that fails with “No such property: name for class: org.gradle.api.internal.plugins.DefaultObjectConfigurationAction”. I’m not sure what is reasonable to do here.
This is obviously more of a Groovy question, but we need to address this in the user guide.
But it appears that the syntax used by “apply” is different from the “conventional” map literal. I can do this:
Map map = [plugin:'java']
but I can’t do:
apply [plugin:'java']
or:
Map map = plugin:'java'
So the “apply” call does not and can not have the wrapping brackets, but a typical place where a map value can be supplied (value assignment, for instance) requires the wrapping brackets.
Cute. So this example isn’t even demonstrating map literals, just something that “looks like” a map literal, which is then internally converted to a map as it’s passed to the method.
This distinction seems like a useful thing to point out. I’ll see if I can expand this example a bit more to clarify this.