Search in sources :

Example 11 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration 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 12 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project maven-plugins by apache.

the class ArtifactTypeMappingServiceTest method testConfigWithSameCustomType.

public void testConfigWithSameCustomType() {
    try {
        XmlPlexusConfiguration rootConfig = new XmlPlexusConfiguration("dummy");
        XmlPlexusConfiguration childConfig = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "generic");
        childConfig.setAttribute("mapping", "rar");
        XmlPlexusConfiguration childConfig2 = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "generic");
        childConfig.setAttribute("mapping", "ejb");
        rootConfig.addChild(childConfig);
        rootConfig.addChild(childConfig2);
        ArtifactTypeMappingService service = new ArtifactTypeMappingService();
        service.configure(rootConfig);
        fail("Should have failed");
    } catch (EarPluginException e) {
    // OK
    } catch (PlexusConfigurationException e) {
        e.printStackTrace();
        fail("Unexpected " + e.getMessage());
    }
}
Also used : PlexusConfigurationException(org.codehaus.plexus.configuration.PlexusConfigurationException) EarPluginException(org.apache.maven.plugins.ear.EarPluginException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)

Example 13 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project maven-plugins by apache.

the class ArtifactTypeMappingServiceTest method getDefaultService.

protected ArtifactTypeMappingService getDefaultService() {
    try {
        ArtifactTypeMappingService service = new ArtifactTypeMappingService();
        service.configure(new XmlPlexusConfiguration("dummy"));
        return service;
    } catch (EarPluginException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (PlexusConfigurationException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    // Won't occur
    return null;
}
Also used : PlexusConfigurationException(org.codehaus.plexus.configuration.PlexusConfigurationException) EarPluginException(org.apache.maven.plugins.ear.EarPluginException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)

Example 14 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project maven-plugins by apache.

the class AntrunXmlPlexusConfigurationWriterTest method setUp.

@Before
public void setUp() throws IOException {
    configurationWriter = new AntrunXmlPlexusConfigurationWriter();
    configuration = new XmlPlexusConfiguration("target");
    configuration.setAttribute("name", TARGET_NAME);
    file = folder.newFile();
}
Also used : XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) Before(org.junit.Before)

Example 15 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project sonatype-aether by sonatype.

the class PlexusWagonConfigurator method configure.

public void configure(Wagon wagon, Object configuration) throws Exception {
    PlexusConfiguration config = null;
    if (configuration instanceof PlexusConfiguration) {
        config = (PlexusConfiguration) configuration;
    } else if (configuration instanceof Xpp3Dom) {
        config = new XmlPlexusConfiguration((Xpp3Dom) configuration);
    } else if (configuration == null) {
        return;
    } else {
        throw new IllegalArgumentException("Unexpected configuration type: " + configuration.getClass().getName());
    }
    WagonComponentConfigurator configurator = new WagonComponentConfigurator();
    configurator.configureComponent(wagon, config, container.getContainerRealm());
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration)

Aggregations

XmlPlexusConfiguration (org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration)23 PlexusConfiguration (org.codehaus.plexus.configuration.PlexusConfiguration)11 EarPluginException (org.apache.maven.plugins.ear.EarPluginException)6 ArtifactTypeMappingService (org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)6 PlexusConfigurationException (org.codehaus.plexus.configuration.PlexusConfigurationException)6 PluginParameterExpressionEvaluator (org.apache.maven.plugin.PluginParameterExpressionEvaluator)4 ExpressionEvaluator (org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator)4 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 ComponentConfigurationException (org.codehaus.plexus.component.configurator.ComponentConfigurationException)3 ComponentConfigurator (org.codehaus.plexus.component.configurator.ComponentConfigurator)3 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)3 ModelNode (org.jboss.dmr.ModelNode)3 IOException (java.io.IOException)2 StringReader (java.io.StringReader)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 MojoDescriptor (org.apache.maven.plugin.descriptor.MojoDescriptor)2 StringWriter (java.io.StringWriter)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1