Java Code Examples for org.apache.maven.project.MavenProject#getContextValue()

The following examples show how to use org.apache.maven.project.MavenProject#getContextValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginPropertyUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: MavenProjectCache.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static MavenExecutionResult getExecutionResult(MavenProject project) {
    return (MavenExecutionResult) project.getContextValue(CONTEXT_EXECUTION_RESULT);
}
 
Example 3
Source File: MavenProjectCache.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean unknownBuildParticipantObserved(MavenProject project) {
    return project.getContextValue(CONTEXT_PARTICIPANTS) != null;
}
 
Example 4
Source File: MavenProjectCache.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * list of class names of build participants in the project, null when none are present.
 * @param project
 * @return 
 */
public static Collection<String> getUnknownBuildParticipantsClassNames(MavenProject project) {
    return (Collection<String>) project.getContextValue(CONTEXT_PARTICIPANTS);
}