Example usage for org.apache.maven.project MavenProject getContextValue

List of usage examples for org.apache.maven.project MavenProject getContextValue

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getContextValue.

Prototype

public Object getContextValue(String key) 

Source Link

Document

Returns context value of this project associated with the given key or null if this project has no such value.

Usage

From source file:org.eclipse.tycho.p2.resolver.P2DependencyResolver.java

License:Open Source License

@Override
public void setupProjects(final MavenSession session, final MavenProject project,
        final ReactorProject reactorProject) {
    TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project
            .getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
    List<TargetEnvironment> environments = configuration.getEnvironments();
    Map<String, IDependencyMetadata> metadata = getDependencyMetadata(session, project, environments,
            OptionalResolutionAction.OPTIONAL);
    Set<Object> primaryMetadata = new LinkedHashSet<Object>();
    Set<Object> secondaryMetadata = new LinkedHashSet<Object>();
    for (Map.Entry<String, IDependencyMetadata> entry : metadata.entrySet()) {
        primaryMetadata.addAll(entry.getValue().getMetadata(true));
        secondaryMetadata.addAll(entry.getValue().getMetadata(false));
    }/*  ww  w  . ja  v  a  2  s  .c om*/
    reactorProject.setDependencyMetadata(true, primaryMetadata);
    reactorProject.setDependencyMetadata(false, secondaryMetadata);
}

From source file:org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.java

License:Open Source License

public void setupProjects(final MavenSession session, final MavenProject project,
        final ReactorProject reactorProject) {
    TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project
            .getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
    List<Map<String, String>> environments = getEnvironments(configuration);
    Map<String, IDependencyMetadata> metadata = getDependencyMetadata(session, project, environments,
            OptionalResolutionAction.OPTIONAL);
    for (Map.Entry<String, IDependencyMetadata> entry : metadata.entrySet()) {
        reactorProject.setDependencyMetadata(entry.getKey(), true, entry.getValue().getMetadata(true));
        reactorProject.setDependencyMetadata(entry.getKey(), false, entry.getValue().getMetadata(false));
    }/*ww w  . ja va  2 s . c o  m*/
}

From source file:org.eclipse.tycho.plugins.p2.publisher.AbstractPublishMojo.java

License:Open Source License

/**
 * Adds the just published installable units into a shared list. The assemble-repository goal
 * eventually uses the units in that list as entry-points for mirroring content into the
 * assembly p2 repository./*from  ww w  . j a  va 2s  .  c  om*/
 */
private void postPublishedIUs(Collection<?> units) {
    final MavenProject project = getProject();
    // TODO use own type for this
    List<Object> publishedIUs = (List<Object>) project.getContextValue(TychoConstants.CTX_PUBLISHED_ROOT_IUS);
    if (publishedIUs == null) {
        publishedIUs = new ArrayList<Object>();
        project.setContextValue(TychoConstants.CTX_PUBLISHED_ROOT_IUS, publishedIUs);
    }
    publishedIUs.addAll(units);
}

From source file:org.owasp.dependencycheck.maven.BaseDependencyCheckMojo.java

License:Apache License

/**
 * Returns the correct output directory depending on if a site is being
 * executed or not./*  w w w  . j  a v a 2 s  .co  m*/
 *
 * @param current the Maven project to get the output directory from
 * @return the directory to write the report(s)
 */
protected File getCorrectOutputDirectory(MavenProject current) {
    final Object obj = current.getContextValue(getOutputDirectoryContextKey());
    if (obj != null && obj instanceof File) {
        return (File) obj;
    }
    File target = new File(current.getBuild().getDirectory());
    if (target.getParentFile() != null && "target".equals(target.getParentFile().getName())) {
        target = target.getParentFile();
    }
    return target;
}

From source file:org.owasp.dependencycheck.maven.Engine.java

License:Apache License

/**
 * Runs the analyzers against all of the dependencies.
 *///  w  w  w.  j  ava 2  s.  c o m
@Override
public void analyzeDependencies() {
    final MavenProject root = getExecutionRoot();
    if (root != null) {
        LOGGER.debug("Checking root project, {}, if updates have already been completed", root.getArtifactId());
    } else {
        LOGGER.debug("Checking root project, null, if updates have already been completed");
    }
    if (root != null && root.getContextValue(UPDATE_EXECUTED_FLAG) != null) {
        System.setProperty(Settings.KEYS.AUTO_UPDATE, Boolean.FALSE.toString());
    }
    super.analyzeDependencies();
    if (root != null) {
        root.setContextValue(UPDATE_EXECUTED_FLAG, Boolean.TRUE);
    }
}

From source file:org.owasp.dependencycheck.maven.Engine.java

License:Apache License

/**
 * Runs the update steps of dependency-check.
 *///  w ww.  jav  a  2 s.co  m
public void update() {
    final MavenProject root = getExecutionRoot();
    if (root != null && root.getContextValue(UPDATE_EXECUTED_FLAG) != null) {
        System.setProperty(Settings.KEYS.AUTO_UPDATE, Boolean.FALSE.toString());
    }
    this.doUpdates();
}

From source file:org.owasp.dependencycheck.maven.Engine.java

License:Apache License

/**
 * Gets the CPEAnalyzer from the root Maven Project.
 *
 * @return an initialized CPEAnalyzer//from  ww  w .  j ava2s .  c  o  m
 */
private CPEAnalyzer getPreviouslyLoadedCPEAnalyzer() {
    CPEAnalyzer cpe = null;
    final MavenProject project = getExecutionRoot();
    if (project != null) {
        final Object obj = project.getContextValue(CPE_ANALYZER_KEY);
        if (obj != null && obj instanceof CPEAnalyzer) {
            cpe = (CPEAnalyzer) project.getContextValue(CPE_ANALYZER_KEY);
        }
    }
    return cpe;
}

From source file:org.owasp.dependencycheck.maven.MavenEngine.java

License:Apache License

/**
 * Runs the analyzers against all of the dependencies.
 *
 * @throws ExceptionCollection thrown if an exception occurred; contains a
 * collection of exceptions that occurred during analysis.
 *//*w  ww.jav  a 2s  .  c om*/
@Override
public void analyzeDependencies() throws ExceptionCollection {
    final MavenProject root = getExecutionRoot();
    if (root != null) {
        LOGGER.debug("Checking root project, {}, if updates have already been completed", root.getArtifactId());
    } else {
        LOGGER.debug("Checking root project, null, if updates have already been completed");
    }
    if (root != null && root.getContextValue(UPDATE_EXECUTED_FLAG) != null) {
        System.setProperty(Settings.KEYS.AUTO_UPDATE, Boolean.FALSE.toString());
    }
    super.analyzeDependencies();
    if (root != null) {
        root.setContextValue(UPDATE_EXECUTED_FLAG, Boolean.TRUE);
    }
}

From source file:org.owasp.dependencycheck.maven.MavenEngine.java

License:Apache License

/**
 * Runs the update steps of dependency-check.
 *
 * @throws UpdateException thrown if there is an exception
 */// w w w  . j a  v  a 2 s .  c o  m
public void update() throws UpdateException {
    final MavenProject root = getExecutionRoot();
    if (root != null && root.getContextValue(UPDATE_EXECUTED_FLAG) != null) {
        System.setProperty(Settings.KEYS.AUTO_UPDATE, Boolean.FALSE.toString());
    }
    this.doUpdates();
}

From source file:org.owasp.dependencycheck.maven.ReportAggregationMojo.java

License:Apache License

/**
 * Returns the output directory for the given project.
 *
 * @param project the Maven project to get the output directory for
 * @return the output directory for the given project
 *//* ww  w .j a  v  a2 s  . c o  m*/
public File getReportOutputDirectory(MavenProject project) {
    final Object o = project.getContextValue(getOutputDirectoryContextKey());
    if (o != null && o instanceof File) {
        return (File) o;
    }
    return null;
}