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;
}
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);
}
}
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);
}
}
}
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());
}
}
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());
}
}
Aggregations