Search in sources :

Example 1 with XmlPlexusConfiguration

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

Example 2 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project intellij-plugins by JetBrains.

the class AdditionalSourceRootUtil method addByGeneratorMojo.

public static void addByGeneratorMojo(MojoExecution mojoExecution, MavenSession session, MavenProject project, Logger logger) {
    final PluginParameterExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);
    final PlexusConfiguration configuration = new XmlPlexusConfiguration(mojoExecution.getConfiguration());
    for (String parameterName : new String[] { "baseOutputDirectory", "outputDirectory" }) {
        collectGeneratedSource(configuration, parameterName, project, expressionEvaluator, logger);
    }
}
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)

Example 3 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project m2e-nar by maven-nar.

the class MavenUtils method getConfiguredMojo.

private static <T extends AbstractMojo> T getConfiguredMojo(MavenSession session, MojoExecution mojoExecution, Class<T> asType, Log log) throws CoreException {
    MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
    PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
    ClassRealm pluginRealm = getMyRealm(pluginDescriptor.getClassRealm().getWorld());
    T mojo;
    try {
        mojo = asType.newInstance();
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Problem when creating mojo", e));
    }
    mojo.setLog(log);
    logger.debug("Configuring mojo " + mojoDescriptor.getId() + " from plugin realm " + pluginRealm);
    Xpp3Dom dom = mojoExecution.getConfiguration();
    PlexusConfiguration pomConfiguration;
    if (dom == null) {
        pomConfiguration = new XmlPlexusConfiguration("configuration");
    } else {
        pomConfiguration = new XmlPlexusConfiguration(dom);
    }
    ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);
    populatePluginFields(mojo, mojoDescriptor, pluginRealm, pomConfiguration, expressionEvaluator);
    return mojo;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) PluginDescriptor(org.apache.maven.plugin.descriptor.PluginDescriptor) ClassRealm(org.codehaus.plexus.classworlds.realm.ClassRealm) MojoDescriptor(org.apache.maven.plugin.descriptor.MojoDescriptor) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) CoreException(org.eclipse.core.runtime.CoreException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) ExpressionEvaluator(org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator) DuplicateRealmException(org.codehaus.plexus.classworlds.realm.DuplicateRealmException) CoreException(org.eclipse.core.runtime.CoreException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 4 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project tycho by eclipse.

the class AbstractTychoMojoTestCase method lookupMojoWithDefaultConfiguration.

/**
 * Returns a mojo configured with the mojo's default configuration.
 */
// workaround for MPLUGINTESTING-46 - see http://jira.codehaus.org/browse/MPLUGINTESTING-46
protected Mojo lookupMojoWithDefaultConfiguration(MavenProject project, MavenSession session, String goal) throws Exception {
    MojoExecution mojoExecution = newMojoExecution(goal);
    Xpp3Dom defaultConfiguration = mojoExecution.getConfiguration();
    // the ResolverExpressionEvaluatorStub of lookupMojo is not sufficient to evaluate the variables in the default configuration
    ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);
    ComponentConfigurator configurator = getContainer().lookup(ComponentConfigurator.class, "basic");
    Mojo mojo = lookupEmptyMojo(goal, project.getFile());
    configurator.configureComponent(mojo, new XmlPlexusConfiguration(defaultConfiguration), expressionEvaluator, getContainer().getContainerRealm(), null);
    return mojo;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) Mojo(org.apache.maven.plugin.Mojo) MojoExecution(org.apache.maven.plugin.MojoExecution) ComponentConfigurator(org.codehaus.plexus.component.configurator.ComponentConfigurator) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) ExpressionEvaluator(org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator)

Example 5 with XmlPlexusConfiguration

use of org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration in project revapi by revapi.

the class SchemaDrivenJSONToXmlConverter method convertArray.

private static PlexusConfiguration convertArray(ModelNode configuration, ConversionContext ctx) {
    ModelNode itemsSchema = ctx.currentSchema.get("items");
    if (!itemsSchema.isDefined()) {
        throw new IllegalArgumentException("No schema found for items of a list. Cannot continue with XML-to-JSON conversion.");
    }
    PlexusConfiguration list = new XmlPlexusConfiguration(ctx.tagName);
    if (ctx.id != null) {
        list.setAttribute("id", ctx.id);
    }
    for (ModelNode childConfig : configuration.asList()) {
        ctx.tagName = "item";
        ctx.currentSchema = itemsSchema;
        ctx.id = null;
        ctx.currentPath.push("[]");
        PlexusConfiguration child = convert(childConfig, ctx);
        ctx.currentPath.pop();
        list.addChild(child);
    }
    return list;
}
Also used : XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ModelNode(org.jboss.dmr.ModelNode)

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