Search in sources :

Example 16 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project docker-maven-plugin by fabric8io.

the class MojoExecutionServiceTest method createPluginDescriptor.

// ============================================================================================
private MojoDescriptor createPluginDescriptor() throws XmlPullParserException, IOException {
    MojoDescriptor descriptor = new MojoDescriptor();
    PlexusConfiguration config = new XmlPlexusConfiguration(Xpp3DomBuilder.build(new StringReader("<config name='test'><test>1</test></config>")));
    descriptor.setMojoConfiguration(config);
    return descriptor;
}
Also used : MojoDescriptor(org.apache.maven.plugin.descriptor.MojoDescriptor) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) StringReader(java.io.StringReader) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration)

Example 17 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project wildfly-swarm by wildfly-swarm.

the class MultiStartMojo method startArtifact.

@SuppressWarnings("unchecked")
protected void startArtifact(Artifact artifact, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
    List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get(SWARM_PROCESS);
    if (procs == null) {
        procs = new ArrayList<>();
        getPluginContext().put(SWARM_PROCESS, procs);
    }
    SwarmExecutor executor = new SwarmExecutor();
    executor.withExecutableJar(artifact.getFile().toPath());
    executor.withProperties(this.properties);
    executor.withEnvironment(this.environment);
    PlexusConfiguration props = process.getChild("properties");
    for (PlexusConfiguration each : props.getChildren()) {
        executor.withProperty(each.getName(), each.getValue());
    }
    PlexusConfiguration env = process.getChild("environment");
    for (PlexusConfiguration each : env.getChildren()) {
        executor.withEnvironment(each.getName(), each.getValue());
    }
    int startTimeoutSeconds;
    try {
        startTimeoutSeconds = Integer.valueOf(props.getChild("start.timeout.seconds").getValue("30"));
    } catch (NumberFormatException nfe) {
        throw new IllegalArgumentException("Wrong format of the start timeout for " + artifact + "!. Integer expected.", nfe);
    }
    try {
        SwarmProcess launched = executor.execute();
        launched.awaitReadiness(startTimeoutSeconds, TimeUnit.SECONDS);
        procs.add(launched);
    } catch (IOException | InterruptedException e) {
        throw new MojoFailureException("Unable to execute: " + artifact, e);
    }
}
Also used : XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) SwarmExecutor(org.wildfly.swarm.tools.exec.SwarmExecutor) MojoFailureException(org.apache.maven.plugin.MojoFailureException) IOException(java.io.IOException) SwarmProcess(org.wildfly.swarm.tools.exec.SwarmProcess) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project wildfly-swarm by wildfly-swarm.

the class MultiStartMojo method executeSpecific.

@Override
public void executeSpecific() throws MojoExecutionException, MojoFailureException {
    initProperties(true);
    initEnvironment();
    for (XmlPlexusConfiguration process : this.processes) {
        try {
            start(process);
        } catch (Exception e) {
            throw new MojoFailureException("Unable to start", e);
        }
    }
}
Also used : MojoFailureException(org.apache.maven.plugin.MojoFailureException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PluginManagerException(org.apache.maven.plugin.PluginManagerException) PluginResolutionException(org.apache.maven.plugin.PluginResolutionException) PluginDescriptorParsingException(org.apache.maven.plugin.PluginDescriptorParsingException) PluginConfigurationException(org.apache.maven.plugin.PluginConfigurationException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) InvalidPluginDescriptorException(org.apache.maven.plugin.InvalidPluginDescriptorException) PluginNotFoundException(org.apache.maven.plugin.PluginNotFoundException)

Example 19 with XmlPlexusConfiguration

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

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

the class ArtifactTypeMappingServiceTest method testConfigWithNoMapping.

public void testConfigWithNoMapping() {
    try {
        XmlPlexusConfiguration rootConfig = new XmlPlexusConfiguration("dummy");
        XmlPlexusConfiguration childConfig = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "generic");
        rootConfig.addChild(childConfig);
        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)

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