本文整理汇总了Java中org.apache.maven.plugin.PluginParameterExpressionEvaluator类的典型用法代码示例。如果您正苦于以下问题:Java PluginParameterExpressionEvaluator类的具体用法?Java PluginParameterExpressionEvaluator怎么用?Java PluginParameterExpressionEvaluator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PluginParameterExpressionEvaluator类属于org.apache.maven.plugin包,在下文中一共展示了PluginParameterExpressionEvaluator类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTagName
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
/**
* Calculates an SCM tag name based on a pattern. This pattern can include every parameter reference that can be
* resolved by <a href=
* "https://maven.apache.org/ref/3.3.9/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html">PluginParameterExpressionEvaluator</a>.
*
* @param pattern the pattern for the tag name which may contain variables listed above.
* @param project the Maven project to be used for version calculation during parameter resolution.
* @param evaluator the Maven plugin parameter expression evaluator used to evaluate expressions containing parameter
* references.
* @return the name of the tag derived from the pattern.
*/
public static String getTagName(String pattern, MavenProject project, PluginParameterExpressionEvaluator evaluator) {
Preconditions.checkArgument(pattern != null, "Need a tag name pattern to calculate the tag name.");
Preconditions.checkArgument(evaluator != null, "Need an expression evaluator to calculate the tag name.");
try {
StringBuilder sb = new StringBuilder(pattern);
int start = -1;
while ((start = sb.indexOf("@{")) > -1) {
int end = sb.indexOf("}");
String var = sb.substring(start + 2, end);
String resolved;
// the parameter project.version gets a special treatment and will not be resolved by the evaluator but gets the
// release version instead
if (Objects.equal("project.version", var)) {
resolved = MavenVersionUtil.calculateReleaseVersion(project.getVersion());
} else {
String expression = "${" + var + "}";
resolved = evaluator.evaluate(expression).toString();
}
sb.replace(start, end + 1, resolved);
}
return sb.toString();
} catch (ExpressionEvaluationException e) {
throw new RuntimeException("Could not resolve expressions in pattern: " + pattern, e);
}
}
示例2: expandProjectVariables
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
public void expandProjectVariables(PluginParameterExpressionEvaluator expressionEvaluator) {
if (this.variablesExpanded) {
return;
}
expandUnmappedData(expressionEvaluator);
expandMappedData(expressionEvaluator);
this.variablesExpanded = true;
}
示例3: expand
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
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);
}
}
示例4: WorkflowExecutor
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
public WorkflowExecutor(ProcessingWorkflow workflow, Map<String, CDIMojoProcessingStep> processingSteps, Log log,
PluginParameterExpressionEvaluator expressionEvaluator) {
this.workflow = workflow;
this.processingSteps = processingSteps;
this.log = log;
this.expressionEvaluator = expressionEvaluator;
}
示例5: execute
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
if (System.getProperty(SYSPROP_PRINT_WF) != null) {
WorkflowUtil.printWorkflow(getGoalName(), getPluginDescriptor(), Optional.fromNullable(this.workflowDescriptor),
createLogWrapper());
return;
}
System.setProperty("org.jboss.logging.provider", "slf4j");
String logLevel = "info";
if (getLog().isDebugEnabled()) {
logLevel = "debug";
}
System.setProperty("org.slf4j.simpleLogger.log.org.jboss.weld", logLevel);
Weld weld = new Weld();
weld.addExtension(this);
addPluginDependencies(weld);
WeldContainer weldContainer = null;
try {
weldContainer = weld.initialize();
if (System.getProperty(SYSPROP_PRINT_STEPS) != null) {
WorkflowUtil.printAvailableSteps(this.allAvailableProcessingSteps, createLogWrapper());
return;
}
WorkflowUtil.addExecutionContexts(getWorkflow());
Map<String, CDIMojoProcessingStep> processingSteps = getAllProcessingSteps(weldContainer);
PluginParameterExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(this._session,
this._mojoExecution);
WorkflowExecutor executor = new WorkflowExecutor(getWorkflow(), processingSteps, getLog(), expressionEvaluator);
executor.validate(!this._settings.isOffline());
executor.execute();
} finally {
if (weldContainer != null && weldContainer.isRunning()) {
weldContainer.shutdown();
}
}
}
示例6: getString
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
@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;
}
示例7: evalPluginParameterExpression
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
private Object evalPluginParameterExpression(String expression) {
PluginParameterExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(mavenSession, mojoExecution);
try {
return evaluator.evaluate(expression);
} catch (ExpressionEvaluationException e) {
getLog().error("Failed to evaluate [" + expression + "]", e);
}
return null;
}
示例8: getExpressionEvaluator
import org.apache.maven.plugin.PluginParameterExpressionEvaluator; //导入依赖的package包/类
@MojoProduces
private PluginParameterExpressionEvaluator getExpressionEvaluator() {
return new PluginParameterExpressionEvaluator(this.session, this.mojoExecution);
}