Search in sources :

Example 1 with ComponentConfigurationException

use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project flyway by flyway.

the class IncludeProjectDependenciesComponentConfigurator method addProjectDependenciesToClassRealm.

@SuppressWarnings({ "unchecked" })
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException {
    List<String> classpathElements;
    try {
        classpathElements = (List<String>) expressionEvaluator.evaluate("${project.testClasspathElements}");
    } catch (ExpressionEvaluationException e) {
        throw new ComponentConfigurationException("There was a problem evaluating: ${project.testClasspathElements}", e);
    }
    // Add the project dependencies to the ClassRealm
    final URL[] urls = buildURLs(classpathElements);
    for (URL url : urls) {
        containerRealm.addConstituent(url);
    }
}
Also used : ExpressionEvaluationException(org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException) URL(java.net.URL) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 2 with ComponentConfigurationException

use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project maven-plugins by apache.

the class AbstractDeployMojo method configureWagon.

/**
 * Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
 *
 * @param wagon
 * @param repositoryId
 * @param settings
 * @param container
 * @param log
 * @throws TransferFailedException
 * @todo Remove when {@link WagonManager#getWagon(Repository) is available}. It's available in Maven 2.0.5.
 */
private static void configureWagon(Wagon wagon, String repositoryId, Settings settings, PlexusContainer container, Log log) throws TransferFailedException {
    log.debug(" configureWagon ");
    // MSITE-25: Make sure that the server settings are inserted
    for (Server server : settings.getServers()) {
        String id = server.getId();
        log.debug("configureWagon server " + id);
        if (id != null && id.equals(repositoryId) && (server.getConfiguration() != null)) {
            final PlexusConfiguration plexusConf = new XmlPlexusConfiguration((Xpp3Dom) server.getConfiguration());
            ComponentConfigurator componentConfigurator = null;
            try {
                componentConfigurator = (ComponentConfigurator) container.lookup(ComponentConfigurator.ROLE, "basic");
                if (isMaven3OrMore()) {
                    componentConfigurator.configureComponent(wagon, plexusConf, container.getContainerRealm());
                } else {
                    configureWagonWithMaven2(componentConfigurator, wagon, plexusConf, container);
                }
            } catch (final ComponentLookupException e) {
                throw new TransferFailedException("While configuring wagon for \'" + repositoryId + "\': Unable to lookup wagon configurator." + " Wagon configuration cannot be applied.", e);
            } catch (ComponentConfigurationException e) {
                throw new TransferFailedException("While configuring wagon for \'" + repositoryId + "\': Unable to apply wagon configuration.", e);
            } finally {
                if (componentConfigurator != null) {
                    try {
                        container.release(componentConfigurator);
                    } catch (ComponentLifecycleException e) {
                        log.error("Problem releasing configurator - ignoring: " + e.getMessage());
                    }
                }
            }
        }
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) Server(org.apache.maven.settings.Server) ComponentConfigurator(org.codehaus.plexus.component.configurator.ComponentConfigurator) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) ComponentLifecycleException(org.codehaus.plexus.component.repository.exception.ComponentLifecycleException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) TransferFailedException(org.apache.maven.wagon.TransferFailedException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 3 with ComponentConfigurationException

use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project maven-plugins by apache.

the class DefaultAssemblyArchiver method configureContainerDescriptorHandler.

private void configureContainerDescriptorHandler(final ContainerDescriptorHandler handler, final Xpp3Dom config, final AssemblerConfigurationSource configSource) throws InvalidAssemblerConfigurationException {
    getLogger().debug("Configuring handler: '" + handler.getClass().getName() + "' -->");
    try {
        configureComponent(handler, config, configSource);
    } catch (final ComponentConfigurationException e) {
        throw new InvalidAssemblerConfigurationException("Failed to configure handler: " + handler.getClass().getName(), e);
    } catch (final ComponentLookupException e) {
        throw new InvalidAssemblerConfigurationException("Failed to lookup configurator for setup of handler: " + handler.getClass().getName(), e);
    }
    getLogger().debug("-- end configuration --");
}
Also used : ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) InvalidAssemblerConfigurationException(org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 4 with ComponentConfigurationException

use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project swagger-core by swagger-api.

the class IncludeProjectDependenciesComponentConfigurator method addProjectDependenciesToClassRealm.

private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException {
    List<String> compileClasspathElements;
    try {
        // noinspection unchecked
        compileClasspathElements = (List<String>) expressionEvaluator.evaluate("${project.compileClasspathElements}");
    } catch (ExpressionEvaluationException e) {
        throw new ComponentConfigurationException("There was a problem evaluating: ${project.compileClasspathElements}", e);
    }
    // Add the project dependencies to the ClassRealm
    final URL[] urls = buildURLs(compileClasspathElements);
    for (URL url : urls) {
        containerRealm.addURL(url);
    }
}
Also used : ExpressionEvaluationException(org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException) URL(java.net.URL) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 5 with ComponentConfigurationException

use of org.codehaus.plexus.component.configurator.ComponentConfigurationException in project flyway by flyway.

the class IncludeProjectDependenciesComponentConfigurator method buildURLs.

private URL[] buildURLs(List<String> classpathElements) throws ComponentConfigurationException {
    // Add the projects classes and dependencies
    List<URL> urls = new ArrayList<URL>(classpathElements.size());
    for (String element : classpathElements) {
        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