Search in sources :

Example 6 with ComponentConfigurationException

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 --");
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) StringReader(java.io.StringReader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 7 with ComponentConfigurationException

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());
    }
}
Also used : DebugConfigurationListener(org.apache.maven.plugin.DebugConfigurationListener) AssemblyExpressionEvaluator(org.apache.maven.plugins.assembly.interpolation.AssemblyExpressionEvaluator) ComponentConfigurator(org.codehaus.plexus.component.configurator.ComponentConfigurator) Method(java.lang.reflect.Method) AssemblyExpressionEvaluator(org.apache.maven.plugins.assembly.interpolation.AssemblyExpressionEvaluator) ExpressionEvaluator(org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator) InvocationTargetException(java.lang.reflect.InvocationTargetException) DebugConfigurationListener(org.apache.maven.plugin.DebugConfigurationListener) ConfigurationListener(org.codehaus.plexus.component.configurator.ConfigurationListener) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 8 with ComponentConfigurationException

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);
    }
}
Also used : ClassRealm(org.codehaus.classworlds.ClassRealm) Method(java.lang.reflect.Method) AuthenticationException(org.apache.maven.wagon.authentication.AuthenticationException) CommandExecutionException(org.apache.maven.wagon.CommandExecutionException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException) ComponentLifecycleException(org.codehaus.plexus.component.repository.exception.ComponentLifecycleException) TransferFailedException(org.apache.maven.wagon.TransferFailedException) ConnectionException(org.apache.maven.wagon.ConnectionException) AuthorizationException(org.apache.maven.wagon.authorization.AuthorizationException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) ContextException(org.codehaus.plexus.context.ContextException) UnsupportedProtocolException(org.apache.maven.wagon.UnsupportedProtocolException) MalformedURLException(java.net.MalformedURLException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ResourceDoesNotExistException(org.apache.maven.wagon.ResourceDoesNotExistException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 9 with ComponentConfigurationException

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()]);
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) File(java.io.File) URL(java.net.URL) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Aggregations

ComponentConfigurationException (org.codehaus.plexus.component.configurator.ComponentConfigurationException)9 URL (java.net.URL)4 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)4 MalformedURLException (java.net.MalformedURLException)3 File (java.io.File)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 TransferFailedException (org.apache.maven.wagon.TransferFailedException)2 ComponentConfigurator (org.codehaus.plexus.component.configurator.ComponentConfigurator)2 ExpressionEvaluationException (org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException)2 ComponentLifecycleException (org.codehaus.plexus.component.repository.exception.ComponentLifecycleException)2 XmlPlexusConfiguration (org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DebugConfigurationListener (org.apache.maven.plugin.DebugConfigurationListener)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 InvalidAssemblerConfigurationException (org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException)1 AssemblyExpressionEvaluator (org.apache.maven.plugins.assembly.interpolation.AssemblyExpressionEvaluator)1 Server (org.apache.maven.settings.Server)1