PlexusConfiguration configuration,
PlexusContainer pluginContainer,
ExpressionEvaluator expressionEvaluator )
throws PluginConfigurationException
{
ComponentConfigurator configurator = null;
try
{
String configuratorId = mojoDescriptor.getComponentConfigurator();
// TODO: could the configuration be passed to lookup and the configurator known to plexus via the descriptor
// so that this meethod could entirely be handled by a plexus lookup?
if ( StringUtils.isNotEmpty( configuratorId ) )
{
configurator =
(ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId );
}
else
{
configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE );
}
ConfigurationListener listener = new DebugConfigurationListener( getLogger() );
getLogger().debug( "Configuring mojo '" + mojoDescriptor.getId() + "' -->" );
configurator.configureComponent( plugin, configuration, expressionEvaluator,
pluginContainer.getContainerRealm(), listener );
getLogger().debug( "-- end configuration --" );
}
catch ( ComponentConfigurationException e )
{
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
"Unable to parse the created DOM for plugin configuration", e );
}
catch ( ComponentLookupException e )
{
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
"Unable to retrieve component configurator for plugin configuration",
e );
}
catch ( NoClassDefFoundError e )
{
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
"A required class was missing during mojo configuration: " + e.getMessage(), e );
}
catch ( LinkageError e )
{
if ( getLogger().isFatalErrorEnabled() )
{
getLogger().fatalError(
configurator.getClass().getName() + "#configureComponent(...) caused a linkage error ("
+ e.getClass().getName() + ") and may be out-of-date. Check the realms:" );
ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm();
StringBuffer sb = new StringBuffer();
sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' );