On 11/02/2011, at 11:52 PM, Runar Myklebust wrote:
> Hi.
>
> Id like to apply a list of values to a custom plugin, with a configuration in
> the build-file like:
>
> locations {
> Location name: location1, url: http..., etc
> Location name: location2, url:...
> Location name: location3, url:...
> ..
> }
>
> As a result, id like a LocationsConvention in my plugin with a list of all
> the locations
>
> class LocationsConvention
> {
> List<Location> locations;
>
> Location getLocation(String name)
> {
> ..
> }
> }
>
> Is this possible?
To some degree. The Project.container() method, add in 0.9.2, is intended to
help you solve this problem, but currently you still need to write a bit of
code in your plugin. Have a look at this example in the user guide:
http://gradle.org/0.9.2/docs/userguide/custom_plugins.html#N14570
The container() implementation doesn't allow map-based configuration at the
moment, so your build script would look more like this:
locations {
location1 {
url = ...
}
location2 {
url = ...
}
}
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz