Search in sources :

Example 6 with PlexusConfiguration

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);
        }
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) EarPluginException(org.apache.maven.plugins.ear.EarPluginException) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with PlexusConfiguration

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;
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) ArrayList(java.util.ArrayList)

Example 8 with PlexusConfiguration

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);
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) ValueSource(org.codehaus.plexus.interpolation.ValueSource) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource) ArrayList(java.util.ArrayList) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource)

Example 9 with PlexusConfiguration

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());
                    }
                }
            }
        }
    }
}
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 10 with PlexusConfiguration

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);
    }
}
Also used : PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) ExpressionEvaluator(org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator)

Aggregations

PlexusConfiguration (org.codehaus.plexus.configuration.PlexusConfiguration)19 ArrayList (java.util.ArrayList)5 XmlPlexusConfiguration (org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration)5 Map (java.util.Map)2 PluginParameterExpressionEvaluator (org.apache.maven.plugin.PluginParameterExpressionEvaluator)2 InterpolationException (org.codehaus.plexus.interpolation.InterpolationException)2 MapBasedValueSource (org.codehaus.plexus.interpolation.MapBasedValueSource)2 StringSearchInterpolator (org.codehaus.plexus.interpolation.StringSearchInterpolator)2 ValueSource (org.codehaus.plexus.interpolation.ValueSource)2 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 HashMap (java.util.HashMap)1 List (java.util.List)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 CheckstyleExecutorException (org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException)1 CheckstyleExecutorRequest (org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest)1