Example usage for org.apache.maven.project DefaultProjectBuildingRequest setValidationLevel

List of usage examples for org.apache.maven.project DefaultProjectBuildingRequest setValidationLevel

Introduction

In this page you can find the example usage for org.apache.maven.project DefaultProjectBuildingRequest setValidationLevel.

Prototype

public ProjectBuildingRequest setValidationLevel(int validationLevel) 

Source Link

Usage

From source file:org.apache.marmotta.maven.plugins.refpack.RefPackMojo.java

License:Apache License

private Model getArtifactModel(Artifact artifact) {
    org.apache.maven.artifact.Artifact mavenArtifact = artifactFactory.createArtifact(artifact.getGroupId(),
            artifact.getArtifactId(), artifact.getVersion(), "runtime", artifact.getExtension());

    DefaultProjectBuildingRequest req = new DefaultProjectBuildingRequest();
    req.setRepositorySession(session);//w ww.  j  av a 2  s.co  m
    req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_STRICT);

    try {
        ProjectBuildingResult res = projectBuilder.build(mavenArtifact, req);

        return res.getProject().getModel();
    } catch (ProjectBuildingException e) {
        getLog().warn("error building artifact model for artifact " + artifact, e);
        return null;
    }

}

From source file:org.commonjava.emb.boot.services.DefaultEMBServiceManager.java

License:Apache License

public DefaultProjectBuildingRequest createProjectBuildingRequest() throws EMBEmbeddingException {
    final DefaultProjectBuildingRequest req = new DefaultProjectBuildingRequest();
    req.setLocalRepository(defaultLocalRepository());
    req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
    req.setProcessPlugins(false);/*from  w  w  w . j  av a 2 s.c o  m*/
    req.setResolveDependencies(false);

    req.setRepositorySession(createAetherRepositorySystemSession());

    return req;
}

From source file:org.commonjava.poc.ral.AppLauncher.java

License:Open Source License

private DependencyGraph resolveDependencies(final MavenProject project, final SimpleProjectToolsSession session)
        throws AppLauncherException {
    if (LOGGER.isDebugEnabled()) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Setting up repository session to resolve dependencies...");
        }/*from  ww  w .ja va 2  s . co  m*/
    }
    final DefaultProjectBuildingRequest pbr;
    try {
        sessionInitializer.initializeSessionComponents(session);

        pbr = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
        pbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
        session.setProjectBuildingRequest(pbr);
    } catch (final MAEException e) {
        throw new AppLauncherException("Failed to initialize workspace for capture analysis: %s", e,
                e.getMessage());
    }

    final DefaultRepositorySystemSession rss = (DefaultRepositorySystemSession) pbr.getRepositorySession();

    if (LOGGER.isDebugEnabled()) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Resolving dependency graph...");
        }
    }

    Collection<MavenProject> projects = Collections.singleton(project);

    final DependencyGraph depGraph = graphResolver.accumulateGraph(projects, rss, session);
    graphResolver.resolveGraph(depGraph, projects, rss, session);

    return depGraph;
}

From source file:org.evosuite.maven.util.EvoSuiteRunner.java

License:Open Source License

/**
 * We run the EvoSuite that is provided with the plugin
 * /*from w  w w.  ja  v a2  s  .co m*/
 * @return
 */
private List<String> getCommandToRunEvoSuite() {

    logger.debug("EvoSuite Maven Plugin Artifacts: " + Arrays.toString(artifacts.toArray()));

    Artifact evosuite = null;

    for (Artifact art : artifacts) {
        //first find the main EvoSuite jar among the dependencies
        if (art.getArtifactId().equals("evosuite-master")) {
            evosuite = art;
            break;
        }
    }

    if (evosuite == null) {
        logger.error("CRITICAL ERROR: plugin can detect EvoSuite executable");
        return null;
    }

    logger.debug("EvoSuite located at: " + evosuite.getFile());

    /*
     * now, build a project descriptor for evosuite, which is needed to
     * query all of its dependencies 
     */
    DefaultProjectBuildingRequest req = new DefaultProjectBuildingRequest();
    req.setRepositorySession(repoSession);
    req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
    req.setSystemProperties(System.getProperties());
    req.setResolveDependencies(true);

    ProjectBuildingResult res;

    try {
        res = projectBuilder.build(evosuite, req);
    } catch (ProjectBuildingException e) {
        logger.error("Failed: " + e.getMessage(), e);
        return null;
    }

    //build the classpath to run EvoSuite
    String cp = evosuite.getFile().getAbsolutePath();

    for (Artifact dep : res.getProject().getArtifacts()) {
        cp += File.pathSeparator + dep.getFile().getAbsolutePath();
    }
    logger.debug("EvoSuite classpath: " + cp);

    String entryPoint = EvoSuite.class.getName();

    List<String> cmd = new ArrayList<>();
    cmd.add("java");
    cmd.add("-D" + LoggingUtils.USE_DIFFERENT_LOGGING_XML_PARAMETER + "=logback-ctg-entry.xml");
    cmd.add("-Dlogback.configurationFile=logback-ctg-entry.xml");
    cmd.add("-cp");
    cmd.add(cp);
    cmd.add(entryPoint);
    return cmd;
}