public ConfigHandler( Object mojo, MavenSession session, MojoExecution execution ) { this.mojo = mojo; if ( session == null ) { throw new IllegalArgumentException( "The argument session is required" ); } if ( execution == null ) { throw new IllegalArgumentException( "The argument execution is required" ); } this.evaluator = new PluginParameterExpressionEvaluator( session, execution ); initConfigPojo(); }
@Override public Object evaluate( String expr ) throws ExpressionEvaluationException { return evaluate( expr, null ); }
String expression = stripTokens( expr ); if ( expression.equals( expr ) ) Object subResult = evaluate( expr.substring( index, lastIndex + 1 ) ); retVal += evaluate( expr.substring( lastIndex + 1 ) ); return retVal; if ( value != null && type != null && !( value instanceof String ) && !isTypeCompatible( type, value ) ) value = val.substring( 0, exprStartDelimiter ) + evaluate( val.substring( exprStartDelimiter ) ); value = evaluate( val.substring( exprStartDelimiter ) );
@SuppressWarnings("unchecked") protected void populateSystemProperties() throws ExpressionEvaluationException{ PluginParameterExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session); if(systemProperties!=null){ for(String key: systemProperties.keySet()){ Object val = evaluator.evaluate(systemProperties.get(key)); if(val!=null){ System.setProperty(key, val.toString()); if(getLog().isDebugEnabled()){ getLog().debug("Setting system property "+key+" = "+val); } if("groovity.defaultBinding".equals(key)){ defaultBinding= (Map<String, Object>) new JsonSlurper().parse(new StringReader(val.toString())); } } } } }
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution );
final Object defValue = evaluator.evaluate( defaultValue[0], fieldType );
private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution) { return new PluginParameterExpressionEvaluator( session, mojoExecution ); }
private String expand(String s, PluginParameterExpressionEvaluator expressionEvaluator) { String var = s.replace("@{", "${"); try { String evaluated = expressionEvaluator.evaluate(var).toString(); return evaluated; } catch (ExpressionEvaluationException e) { throw new RuntimeException(e.getMessage(), e); } }
ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator( session, execution );
} else { String expression = "${" + var + "}"; resolved = evaluator.evaluate(expression).toString();
@MojoProduces private PluginParameterExpressionEvaluator getExpressionEvaluator() { return new PluginParameterExpressionEvaluator(this.session, this.mojoExecution); }
} else { String expression = "${" + var + "}"; resolved = evaluator.evaluate(expression).toString();
@MojoProduces private PluginParameterExpressionEvaluator getExpressionEvaluator() { return new PluginParameterExpressionEvaluator(this.session, this.mojoExecution); }
Object evaluate = pluginParameterExpressionEvaluator.evaluate(path.toString()); path = new StringBuilder(evaluate.toString()); } catch (ExpressionEvaluationException e) {
protected void init() throws MojoExecutionException { PluginParameterExpressionEvaluator pluginParameterExpressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution); getContext().getBeanFactory().registerResolvableDependency(PluginParameterExpressionEvaluator.class, pluginParameterExpressionEvaluator); try { initializeConfig(); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Failed to initialize lint-maven-plugin", e); } catch (IOException e) { throw new MojoExecutionException("Failed to initialize lint-maven-plugin", e); } }
@CheckForNull private String getString(MavenProject pom, String parameter) { MavenProject oldProject = session.getCurrentProject(); try { // Switch to the project for which we try to resolve the property. session.setCurrentProject(pom); for (MojoExecution exec : mojoExecutions) { Xpp3Dom configuration = exec.getConfiguration(); PlexusConfiguration pomConfiguration = new XmlPlexusConfiguration(configuration); PlexusConfiguration config = pomConfiguration.getChild(parameter); ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, exec); BasicStringConverter converter = new BasicStringConverter(); String value = converter.fromExpression(config, expressionEvaluator); if (value != null) { return value; } } } catch (Exception e) { log.warn(String.format("Failed to get parameter '%s' for goal '%s': %s", parameter, COMPILE_GOAL, e.getMessage())); } finally { session.setCurrentProject(oldProject); } return null; }
List<String> errors = new ArrayList<String>(); PlexusConfiguration configuration = new XmlPlexusConfiguration(dom); ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, execution); for (PlexusConfiguration child : configuration.getChildren()) { String name = fromXML(child.getName());
public MojoInfo(ExecutionEvent event, long startTime) { this(event.getMojoExecution(), null, new XmlPlexusConfiguration( event.getMojoExecution().getConfiguration() ), new PluginParameterExpressionEvaluator( event.getSession(), event.getMojoExecution() ), startTime); }
/** * 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; }
new PluginParameterExpressionEvaluator( session, mojoExecution, pathTranslator, logger, mavenProject, mavenProject.getProperties() );