How can I apply plugin as Map in Gradle? We can use:
Map<String, String> map = new HashMap<String, String>()
map.put('plugin', 'java')
apply(map)
But when write:
apply [plugin:'java']
An error occured. Why?
The correct Groovy syntax to pass a map to a method is apply the: "map"
or apply([the: "map"])
. apply[...]
is subscript syntax (such as when indexing into an array) which isn't defined here.
apply([plugin:'java'])
or apply plugin:'java'
will work but not apply[plugin:'java']
.
apply
, most likely, is groovy method call and someMethod[key:value]
is not valid groovy method call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.