Sorry for the late reply.

The default is to be a singleton, but I think it only lives as long as
it's ref count is > 0. So you probably want to set it to the true
singleton. I remember seeing someone note this recently for something
else, but I don't know if it exists in the current version of Maven.

In the interim, create a static field that is initialised to the
component on first use. That's obviously a bit gross but it will keep
the ref count up until we can determine if the proper way is available.

- Brett

Mauro Botelho wrote:
> I created a new library like you suggested, and modified both the checkstyle
> an pmd plugins to use it by adding the new library as a dependency. When I
> run them individually everything works fine and I see their metrics being
> reported, but when I try to run both in the same build, I only see the
> metrics of the last plugin run (in my case checkstyle).
> 
> I think this has to do with classloading and the way plexus loads its
> components. The metrics library has a components.xml file in its jar, so I
> think that the registry singleton is being created by the plugin
> classloader.
> 
> What would be the best way to ensure that the registry is a singleton for
> the build?
> 
> Here's my components.xml:
> 
> <component-set>
>   <components>
>     <component>
>       <role>org.apache.maven.metrics.MetricRegistry</role>
>       <implementation>org.apache.maven.metrics.DefaultMetricRegistry
> </implementation>
>     </component>
>   </components>
> </component-set>
> 
> 
> Mauro
> 
> On 2/19/06, Brett Porter <[EMAIL PROTECTED]> wrote:
>> It would just need to be a common dependency. reporting-api definitely
>> is, but you could easily create a new library for it (and that probably
>> makes more sense).
>>
>> The component definition goes in the same JAR as the class.
>>
>> - Brett
>>
>> Mauro Botelho wrote:
>>> Brett, in order for any plug-in to use the MetricRegistry, would it have
>> to
>>> be declared in the reporting-api? Where would I add the component
>> definition
>>> for it?
>>>
>>> Mauro
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to