Search in sources :

Example 41 with MavenExecutionRequest

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

the class AbstractTychoMojoTestCase method getSortedProjects.

protected List<MavenProject> getSortedProjects(File basedir, Properties userProperties, File platform) throws Exception {
    File pom = new File(basedir, "pom.xml");
    MavenExecutionRequest request = newMavenExecutionRequest(pom);
    request.getProjectBuildingRequest().setProcessPlugins(false);
    request.setLocalRepository(getLocalRepository());
    if (platform != null) {
        request.getUserProperties().put("tycho.targetPlatform", platform.getAbsolutePath());
    }
    if (userProperties != null) {
        request.getUserProperties().putAll(userProperties);
    }
    MavenExecutionResult result = maven.execute(request);
    if (result.hasExceptions()) {
        throw new CompoundRuntimeException(result.getExceptions());
    }
    return result.getTopologicallySortedProjects();
}
Also used : DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) File(java.io.File)

Example 42 with MavenExecutionRequest

use of org.apache.maven.execution.MavenExecutionRequest 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 43 with MavenExecutionRequest

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

the class MavenBridge method getMirrors.

public List<Mirror> getMirrors() throws MavenException {
    MavenExecutionRequest request = createExecutionRequest();
    populateDefaults(request);
    return request.getMirrors();
}
Also used : MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest)

Example 44 with MavenExecutionRequest

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

the class MavenBridge method compileAndGenerateJavadoc.

public MavenExecutionResult compileAndGenerateJavadoc(File pom) throws MavenException {
    try {
        MavenExecutionRequest request = createExecutionRequest();
        lookup(MavenExecutionRequestPopulator.class).populateDefaults(request);
        request.setPom(pom);
        ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
        configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
        configuration.setRepositorySession(createRepositorySession(request));
        configuration.setResolveDependencies(true);
        configuration.setResolveVersionRanges(true);
        request.setGoals(Arrays.asList(new String[] { "compile", "javadoc:javadoc" }));
        Properties userProperties = (Properties) request.getUserProperties().clone();
        userProperties.put("show", "private");
        request.setUserProperties(userProperties);
        return lookup(Maven.class).execute(request);
    } catch (MavenExecutionRequestPopulationException e) {
        throw new MavenException(e);
    }
}
Also used : ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) DefaultMaven(org.apache.maven.DefaultMaven) Maven(org.apache.maven.Maven) MavenExecutionRequestPopulationException(org.apache.maven.execution.MavenExecutionRequestPopulationException) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) Properties(java.util.Properties) MavenExecutionRequestPopulator(org.apache.maven.execution.MavenExecutionRequestPopulator)

Example 45 with MavenExecutionRequest

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

the class MavenBridge method getMirror.

public Mirror getMirror(ArtifactRepository repo) throws MavenException {
    MavenExecutionRequest request = createExecutionRequest();
    populateDefaults(request);
    return lookup(RepositorySystem.class).getMirror(repo, request.getMirrors());
}
Also used : RepositorySystem(org.apache.maven.repository.RepositorySystem) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest)

Aggregations

MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)56 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)40 File (java.io.File)24 MavenSession (org.apache.maven.execution.MavenSession)20 MavenExecutionResult (org.apache.maven.execution.MavenExecutionResult)14 MavenProject (org.apache.maven.project.MavenProject)14 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)10 IOException (java.io.IOException)9 MavenExecutionRequestPopulationException (org.apache.maven.execution.MavenExecutionRequestPopulationException)9 MavenExecutionRequestPopulator (org.apache.maven.execution.MavenExecutionRequestPopulator)9 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)8 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)7 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)7 FileNotFoundException (java.io.FileNotFoundException)6 Path (java.nio.file.Path)6 Properties (java.util.Properties)6 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)6 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)6 LifecycleExecutionException (org.apache.maven.lifecycle.LifecycleExecutionException)5 ProjectBuilder (org.apache.maven.project.ProjectBuilder)5