use of org.codehaus.plexus.configuration.PlexusConfiguration in project maven-plugins by apache.
the class ArtifactTypeMappingService method configure.
/**
* @param plexusConfiguration {@link PlexusConfiguration}
* @throws EarPluginException {@link EarPluginException}
* @throws PlexusConfigurationException {@link PlexusConfigurationException}
*/
public void configure(final PlexusConfiguration plexusConfiguration) throws EarPluginException, PlexusConfigurationException {
// No user defined configuration
if (plexusConfiguration == null) {
return;
}
// Inject users configuration
final PlexusConfiguration[] artifactTypeMappings = plexusConfiguration.getChildren(ARTIFACT_TYPE_MAPPING_ELEMENT);
for (PlexusConfiguration artifactTypeMapping : artifactTypeMappings) {
final String customType = artifactTypeMapping.getAttribute(TYPE_ATTRIBUTE);
final String mapping = artifactTypeMapping.getAttribute(MAPPING_ATTRIBUTE);
if (customType == null) {
throw new EarPluginException("Invalid artifact type mapping, type attribute should be set.");
} else if (mapping == null) {
throw new EarPluginException("Invalid artifact type mapping, mapping attribute should be set.");
} else if (!EarModuleFactory.isStandardArtifactType(mapping)) {
throw new EarPluginException("Invalid artifact type mapping, mapping[" + mapping + "] must be a standard Ear artifact type[" + EarModuleFactory.getStandardArtifactTypes() + "]");
} else if (customMappings.containsKey(customType)) {
throw new EarPluginException("Invalid artifact type mapping, type[" + customType + "] is already registered.");
} else {
// Add the custom mapping
customMappings.put(customType, mapping);
// Register the custom mapping to its standard type
List<String> typeMapping = typeMappings.get(mapping);
typeMapping.add(customType);
}
}
}
use of org.codehaus.plexus.configuration.PlexusConfiguration in project maven-plugins by apache.
the class GenerateApplicationXmlMojo method buildSecurityRoles.
/**
* Builds the security roles based on the configuration.
*
* @return a list of SecurityRole object(s)
* @throws EarPluginException if the configuration is invalid
*/
private List<SecurityRole> buildSecurityRoles() throws EarPluginException {
final List<SecurityRole> result = new ArrayList<SecurityRole>();
if (security == null) {
return result;
}
final PlexusConfiguration[] securityRoles = security.getChildren(SecurityRole.SECURITY_ROLE);
for (PlexusConfiguration securityRole : securityRoles) {
final String id = securityRole.getAttribute(SecurityRole.ID_ATTRIBUTE);
final String childRoleName = securityRole.getChild(SecurityRole.ROLE_NAME).getValue();
final String childRoleNameId = securityRole.getChild(SecurityRole.ROLE_NAME).getAttribute(SecurityRole.ID_ATTRIBUTE);
final String childDescription = securityRole.getChild(SecurityRole.DESCRIPTION).getValue();
final String childDescriptionId = securityRole.getChild(SecurityRole.DESCRIPTION).getAttribute(SecurityRole.ID_ATTRIBUTE);
if (childRoleName == null) {
throw new EarPluginException("Invalid security-role configuration, role-name could not be null.");
} else {
result.add(new SecurityRole(childRoleName, childRoleNameId, id, childDescription, childDescriptionId));
}
}
return result;
}
use of org.codehaus.plexus.configuration.PlexusConfiguration in project maven-plugins by apache.
the class GenerateApplicationXmlMojo method buildEnvEntries.
/**
* Builds the env-entries based on the configuration.
*
* @return a list of EnvEntry object(s)
* @throws EarPluginException if the configuration is invalid
*/
private List<EnvEntry> buildEnvEntries() throws EarPluginException {
final List<EnvEntry> result = new ArrayList<EnvEntry>();
if (envEntries == null) {
return result;
}
try {
StringSearchInterpolator ssi = new StringSearchInterpolator();
ValueSource vs = new MapBasedValueSource(project.getProperties());
ssi.addValueSource(vs);
final PlexusConfiguration[] allEnvEntries = envEntries.getChildren(EnvEntry.ENV_ENTRY);
for (PlexusConfiguration envEntry : allEnvEntries) {
// CHECKSTYLE_OFF: LineLength
final String childDescription = interpolate(ssi, envEntry.getChild(EnvEntry.DESCRIPTION).getValue());
final String childEnvEntryName = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_NAME).getValue());
final String childEnvEntryType = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_TYPE).getValue());
final String childEnvEntryValue = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_VALUE).getValue());
try {
result.add(new EnvEntry(childDescription, childEnvEntryName, childEnvEntryType, childEnvEntryValue));
} catch (IllegalArgumentException e) {
throw new EarPluginException("Invalid env-entry [" + envEntry + "]", e);
}
}
return result;
} catch (InterpolationException e) {
throw new EarPluginException("Interpolation exception:", e);
}
}
use of org.codehaus.plexus.configuration.PlexusConfiguration 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());
}
}
}
}
}
}
use of org.codehaus.plexus.configuration.PlexusConfiguration in project intellij-plugins by JetBrains.
the class AdditionalSourceRootUtil method addByBuildHelper.
public static void addByBuildHelper(MojoExecution mojoExecution, MavenSession session, MavenProject project, Logger logger) {
final PlexusConfiguration parentConfiguration = new XmlPlexusConfiguration(mojoExecution.getConfiguration());
final PlexusConfiguration configuration = parentConfiguration.getChild("sources");
if (configuration == null) {
return;
}
final PlexusConfiguration[] sources = configuration.getChildren();
if (sources == null) {
return;
}
final ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);
for (PlexusConfiguration source : sources) {
addFile(evaluate(expressionEvaluator, source.getValue(), logger), project, expressionEvaluator);
}
}
Aggregations