本文整理汇总了Java中org.apache.maven.project.MavenProject.setContextValue方法的典型用法代码示例。如果您正苦于以下问题:Java MavenProject.setContextValue方法的具体用法?Java MavenProject.setContextValue怎么用?Java MavenProject.setContextValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.project.MavenProject
的用法示例。
在下文中一共展示了MavenProject.setContextValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEvaluator
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
/**
* Evaluator usable for interpolating variables in non resolved (interpolated) models.
* Should not be necessary when dealing with the project's <code>MavenProject</code> instance accessed via<code>NbMavenProject.getMavenProject()</code>
* Please NOTE that if you have access to <code>Project</code> instance, then
* the variant with <code>Project</code> as parameter is preferable. Faster and less prone to deadlock.
* @since 2.32
*/
public static @NonNull ExpressionEvaluator createEvaluator(@NonNull MavenProject prj) {
ExpressionEvaluator eval = (ExpressionEvaluator) prj.getContextValue(CONTEXT_EXPRESSION_EVALUATOR);
if (eval != null) {
return eval;
}
Map<? extends String,? extends String> sysprops = Collections.emptyMap();
Map<? extends String,? extends String> userprops = Collections.emptyMap();
File basedir = prj.getBasedir();
if (basedir != null) {
FileObject bsd = FileUtil.toFileObject(basedir);
if (bsd != null) {
Project p = FileOwnerQuery.getOwner(bsd);
if (p != null) {
NbMavenProjectImpl project = p.getLookup().lookup(NbMavenProjectImpl.class);
if (project != null) {
sysprops = project.createSystemPropsForPropertyExpressions();
userprops = project.createUserPropsForPropertyExpressions();
}
}
}
}
//ugly
Settings ss = EmbedderFactory.getProjectEmbedder().getSettings();
ss.setLocalRepository(EmbedderFactory.getProjectEmbedder().getLocalRepository().getBasedir());
eval = new NBPluginParameterExpressionEvaluator(
prj,
ss,
sysprops,
userprops);
prj.setContextValue(CONTEXT_EXPRESSION_EVALUATOR, eval);
return eval;
}