Search in sources :

Example 11 with DefaultMavenExecutionResult

use of org.apache.maven.execution.DefaultMavenExecutionResult in project tycho by eclipse.

the class AbstractTychoMojoTestCase method newMavenSession.

protected MavenSession newMavenSession(MavenProject project, List<MavenProject> projects) throws Exception {
    MavenExecutionRequest request = newMavenExecutionRequest(new File(project.getBasedir(), "pom.xml"));
    MavenExecutionResult result = new DefaultMavenExecutionResult();
    DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
    MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
    session.setProjects(projects);
    session.setCurrentProject(project);
    return session;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) File(java.io.File)

Example 12 with DefaultMavenExecutionResult

use of org.apache.maven.execution.DefaultMavenExecutionResult in project sts4 by spring-projects.

the class MavenBridge method readMavenProject.

public MavenExecutionResult readMavenProject(File pomFile, ProjectBuildingRequest configuration) throws MavenException {
    long start = System.currentTimeMillis();
    // $NON-NLS-1$
    log.debug("Reading Maven project: {}", pomFile.getAbsoluteFile());
    MavenExecutionResult result = new DefaultMavenExecutionResult();
    try {
        configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
        ProjectBuildingResult projectBuildingResult = lookup(ProjectBuilder.class).build(pomFile, configuration);
        result.setProject(projectBuildingResult.getProject());
        result.setDependencyResolutionResult(projectBuildingResult.getDependencyResolutionResult());
    } catch (ProjectBuildingException ex) {
        if (ex.getResults() != null && ex.getResults().size() == 1) {
            ProjectBuildingResult projectBuildingResult = ex.getResults().get(0);
            result.setProject(projectBuildingResult.getProject());
            result.setDependencyResolutionResult(projectBuildingResult.getDependencyResolutionResult());
        }
        result.addException(ex);
    } catch (RuntimeException e) {
        result.addException(e);
    } finally {
        // $NON-NLS-1$
        log.debug("Read Maven project: {} in {} ms", pomFile.getAbsoluteFile(), System.currentTimeMillis() - start);
    }
    return result;
}
Also used : ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) ProjectBuilder(org.apache.maven.project.ProjectBuilder) ProjectBuildingResult(org.apache.maven.project.ProjectBuildingResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult)

Example 13 with DefaultMavenExecutionResult

use of org.apache.maven.execution.DefaultMavenExecutionResult in project sts4 by spring-projects.

the class MavenBridge method createSession.

@SuppressWarnings("deprecation")
public MavenSession createSession(MavenExecutionRequest request, MavenProject project) throws MavenException {
    RepositorySystemSession repoSession = createRepositorySession(request);
    MavenExecutionResult result = new DefaultMavenExecutionResult();
    MavenSession mavenSession = new MavenSession(plexus, repoSession, request, result);
    if (project != null) {
        mavenSession.setProjects(Collections.singletonList(project));
    }
    return mavenSession;
}
Also used : RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) MavenSession(org.apache.maven.execution.MavenSession) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult)

Example 14 with DefaultMavenExecutionResult

use of org.apache.maven.execution.DefaultMavenExecutionResult in project maven-plugins by apache.

the class DefaultDependencyResolverTest method newMavenSession.

protected MavenSession newMavenSession(MavenProject project) {
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    MavenExecutionResult result = new DefaultMavenExecutionResult();
    MavenRepositorySystemSession repoSession = new MavenRepositorySystemSession();
    repoSession.setLocalRepositoryManager(LegacyLocalRepositoryManager.wrap(new StubArtifactRepository("target/local-repo"), null));
    MavenSession session = new MavenSession(getContainer(), repoSession, request, result);
    session.setCurrentProject(project);
    session.setProjects(Arrays.asList(project));
    return session;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository) MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession)

Aggregations

DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)14 MavenSession (org.apache.maven.execution.MavenSession)12 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)9 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)9 MavenExecutionResult (org.apache.maven.execution.MavenExecutionResult)8 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)5 File (java.io.File)4 LegacySupport (org.apache.maven.plugin.LegacySupport)4 PlexusContainer (org.codehaus.plexus.PlexusContainer)4 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)4 StubArtifactRepository (org.apache.maven.plugin.testing.stubs.StubArtifactRepository)3 MavenProject (org.apache.maven.project.MavenProject)3 ManipulationSession (org.commonjava.maven.ext.core.ManipulationSession)3 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)3 DefaultMaven (org.apache.maven.DefaultMaven)2 Maven (org.apache.maven.Maven)2 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)2 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)2 MavenExecutionRequestPopulator (org.apache.maven.execution.MavenExecutionRequestPopulator)2 ProjectBuilder (org.apache.maven.project.ProjectBuilder)2