I went with option two and got it working. I gave the build-info convention 
object its own Convention instance. And created a sub-type of DefaultConvention 
which iterates over the convention objects until one returns a non-null value.

The one thing I couldn't manage was avoiding boilerplate in each getter of the 
build-info convention object that looks like "buildNumber ?: 
convention.getProperty("buildNumber"). I thought I could use getProperty() to 
avoid defining all the boilerplate getters, that didn't work. Either I'm not 
getting how groovy property interception works (which is possible, not a groovy 
expert), or there's something about the way BeanDynamicObject reflectively 
calls properties on convention objects which bypass getProperty(). 


On Monday, September 5, 2011 at 1:40 AM, Adam Murdoch [via Gradle] wrote:

> 
> On 04/09/2011, at 10:46 AM, ansel1 wrote:
> > I've looked at those. The trouble I'm having is that sourceSets supports 
> > additions from otherwise decoupled plugins. But in the case of a simple, 
> > scalar value, it's not clear how to have two plugins provide the value in a 
> > way that keeps trying different plugins until one is successful.
> 
> There's no baked-in support for this. I guess there are a few options:
> 
> * Each plugin sets the value when it is applied (last applied wins). Or as a 
> variation, sets the value if it is null (first applied wins).
> * Each plugin registers a provider (as a Closure or Callable or whatever), 
> and the convention object iterates over until these until it finds one that 
> returns a non-null value.
> 
> This might be something useful to add to the convention mapping stuff, where 
> you can chain the mappings for a property. But first, we'd need to make the 
> convention mapping stuff public.
> 
> 
> --
> Adam Murdoch
> Gradle Co-founder
> http://www.gradle.org
> VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
> http://www.gradleware.com
> 
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below: 
> http://gradle.1045684.n5.nabble.com/Design-advice-for-multiple-plugins-offering-values-for-the-same-project-property-tp4763279p4769301.html
>  
>  To unsubscribe from Design advice for multiple plugins offering values for 
> the same project property, click here 
> (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4763279&code=cnVzc2VsbGVnYW5AZ21haWwuY29tfDQ3NjMyNzl8MTc0MDU1ODM0).
>  
> 
> 




--
View this message in context: 
http://gradle.1045684.n5.nabble.com/Design-advice-for-multiple-plugins-offering-values-for-the-same-project-property-tp4763279p4770823.html
Sent from the gradle-user mailing list archive at Nabble.com.

Reply via email to