use of org.apache.maven.plugin.PluginParameterExpressionEvaluator 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);
}
}
use of org.apache.maven.plugin.PluginParameterExpressionEvaluator 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);
}
}
use of org.apache.maven.plugin.PluginParameterExpressionEvaluator 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;
}
use of org.apache.maven.plugin.PluginParameterExpressionEvaluator 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;
}
use of org.apache.maven.plugin.PluginParameterExpressionEvaluator in project maven-plugins by apache.
the class EvaluateMojo method getEvaluator.
/**
* @return a lazy loading evaluator object.
* @throws MojoExecutionException if any
* @throws MojoFailureException if any reflection exceptions occur or missing components.
*/
private PluginParameterExpressionEvaluator getEvaluator() throws MojoExecutionException, MojoFailureException {
if (evaluator == null) {
MojoDescriptor mojoDescriptor;
try {
mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor("help:evaluate", session, project);
} catch (Exception e) {
throw new MojoFailureException("Failure while evaluating.", e);
}
MojoExecution mojoExecution = new MojoExecution(mojoDescriptor);
MavenProject currentProject = session.getCurrentProject();
// synchronize in case another thread wants to fetch the real current project in between
synchronized (session) {
session.setCurrentProject(project);
evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);
session.setCurrentProject(currentProject);
}
}
return evaluator;
}
Aggregations