use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project maven-plugins by apache.
the class DefaultAssemblyArchiver method configureArchiver.
private void configureArchiver(final Archiver archiver, final AssemblerConfigurationSource configSource) {
Xpp3Dom config;
try {
config = Xpp3DomBuilder.build(new StringReader(configSource.getArchiverConfig()));
} catch (final XmlPullParserException e) {
throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
} catch (final IOException e) {
throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
}
getLogger().debug("Configuring archiver: '" + archiver.getClass().getName() + "' -->");
try {
configureComponent(archiver, config, configSource);
} catch (final ComponentConfigurationException e) {
throw new ArchiverException("Failed to configure archiver: " + archiver.getClass().getName(), e);
} catch (final ComponentLookupException e) {
throw new ArchiverException("Failed to lookup configurator for setup of archiver: " + archiver.getClass().getName(), e);
}
getLogger().debug("-- end configuration --");
}
use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project maven-plugins by apache.
the class DefaultAssemblyArchiver method configureComponent.
private void configureComponent(final Object component, final Xpp3Dom config, final AssemblerConfigurationSource configSource) throws ComponentLookupException, ComponentConfigurationException {
final ComponentConfigurator configurator = container.lookup(ComponentConfigurator.class, "basic");
final ConfigurationListener listener = new DebugConfigurationListener(getLogger());
final ExpressionEvaluator expressionEvaluator = new AssemblyExpressionEvaluator(configSource);
final XmlPlexusConfiguration configuration = new XmlPlexusConfiguration(config);
final Object[] containerRealm = getContainerRealm();
/*
* NOTE: The signature of configureComponent() has changed in Maven 3.x, the reflection prevents a linkage error
* and makes the code work with both Maven 2 and 3.
*/
try {
final Method configureComponent = ComponentConfigurator.class.getMethod("configureComponent", Object.class, PlexusConfiguration.class, ExpressionEvaluator.class, (Class<?>) containerRealm[1], ConfigurationListener.class);
configureComponent.invoke(configurator, component, configuration, expressionEvaluator, containerRealm[0], listener);
} catch (final NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (final IllegalAccessException e) {
throw new RuntimeException(e);
} catch (final InvocationTargetException e) {
if (e.getCause() instanceof ComponentConfigurationException) {
throw (ComponentConfigurationException) e.getCause();
}
throw new RuntimeException(e.getCause());
}
}
use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project maven-plugins by apache.
the class AbstractDeployMojo method configureWagonWithMaven2.
private static void configureWagonWithMaven2(ComponentConfigurator componentConfigurator, Wagon wagon, PlexusConfiguration plexusConf, PlexusContainer container) throws ComponentConfigurationException {
// so use some reflection see MSITE-609
try {
Method methodContainerRealm = container.getClass().getMethod("getContainerRealm");
ClassRealm realm = (ClassRealm) methodContainerRealm.invoke(container);
Method methodConfigure = componentConfigurator.getClass().getMethod("configureComponent", new Class[] { Object.class, PlexusConfiguration.class, ClassRealm.class });
methodConfigure.invoke(componentConfigurator, wagon, plexusConf, realm);
} catch (Exception e) {
throw new ComponentConfigurationException("Failed to configure wagon component for a Maven2 use " + e.getMessage(), e);
}
}
use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project swagger-core by swagger-api.
the class IncludeProjectDependenciesComponentConfigurator method buildURLs.
private URL[] buildURLs(List<String> runtimeClasspathElements) throws ComponentConfigurationException {
// Add the projects classes and dependencies
List<URL> urls = new ArrayList<>(runtimeClasspathElements.size());
for (String element : runtimeClasspathElements) {
try {
final URL url = new File(element).toURI().toURL();
urls.add(url);
} catch (MalformedURLException e) {
throw new ComponentConfigurationException("Unable to access project dependency: " + element, e);
}
}
// Add the plugin's dependencies (so Trove stuff works if Trove isn't on
return urls.toArray(new URL[urls.size()]);
}
Aggregations