Search in sources :

Example 1 with DefaultMavenExecutionResult

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

the class ArtifactDependencyWalkerTest method getTargetPlatform.

protected DependencyArtifacts getTargetPlatform() throws Exception {
    LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setLocalRepository(new StubArtifactRepository(System.getProperty("java.io.tmpdir")));
    MavenExecutionResult result = new DefaultMavenExecutionResult();
    DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
    MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
    session.setProjects(new ArrayList<MavenProject>());
    lookup(LegacySupport.class).setSession(session);
    MavenProject project = new MavenProject();
    resolver.setLocation(new File("src/test/resources/targetplatforms/basic"));
    DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, DefaultReactorProject.adapt(session), null);
    return platform;
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) LegacySupport(org.apache.maven.plugin.LegacySupport) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) MavenSession(org.apache.maven.execution.MavenSession) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) MavenProject(org.apache.maven.project.MavenProject) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository) File(java.io.File)

Example 2 with DefaultMavenExecutionResult

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

the class LocalDependencyResolverTest method getTargetPlatform.

protected DependencyArtifacts getTargetPlatform(File location) throws Exception, IOException {
    LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setLocalRepository(new StubArtifactRepository(location.getAbsolutePath()));
    MavenExecutionResult result = new DefaultMavenExecutionResult();
    DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
    MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
    session.setProjects(new ArrayList<MavenProject>());
    lookup(LegacySupport.class).setSession(session);
    MavenProject project = new MavenProject();
    resolver.setLocation(location);
    DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, DefaultReactorProject.adapt(session), null);
    return platform;
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) LegacySupport(org.apache.maven.plugin.LegacySupport) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) MavenSession(org.apache.maven.execution.MavenSession) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) MavenProject(org.apache.maven.project.MavenProject) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository)

Example 3 with DefaultMavenExecutionResult

use of org.apache.maven.execution.DefaultMavenExecutionResult in project pom-manipulation-ext by release-engineering.

the class VersioningCalculatorTest method setupSession.

private VersioningState setupSession(final Properties properties, final Map<ProjectRef, String[]> versionMap) throws Exception {
    final ArtifactRepository ar = new MavenArtifactRepository("test", "http://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy());
    final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(properties).setRemoteRepositories(Arrays.asList(ar));
    final PlexusContainer container = new DefaultPlexusContainer();
    final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
    session = new ManipulationSession();
    session.setMavenSession(mavenSession);
    final VersioningState state = new VersioningState(properties);
    session.setState(state);
    final Map<String, byte[]> dataMap = new HashMap<>();
    if (versionMap != null && !versionMap.isEmpty()) {
        for (final Map.Entry<ProjectRef, String[]> entry : versionMap.entrySet()) {
            final String path = toMetadataPath(entry.getKey());
            final byte[] data = setupMetadataVersions(entry.getValue());
            dataMap.put(path, data);
        }
    }
    final Location mdLoc = MavenLocationExpander.EXPANSION_TARGET;
    final Transport mdTrans = new StubTransport(dataMap);
    modder = new TestVersionCalculator(new ManipulationSession(), mdLoc, mdTrans, temp.newFolder("galley-cache"));
    return state;
}
Also used : DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) HashMap(java.util.HashMap) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) StubTransport(org.commonjava.maven.ext.core.fixture.StubTransport) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) MavenSession(org.apache.maven.execution.MavenSession) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) VersioningState(org.commonjava.maven.ext.core.state.VersioningState) SimpleProjectRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectRef) ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef) Transport(org.commonjava.maven.galley.spi.transport.Transport) StubTransport(org.commonjava.maven.ext.core.fixture.StubTransport) HashMap(java.util.HashMap) Map(java.util.Map) Location(org.commonjava.maven.galley.model.Location)

Example 4 with DefaultMavenExecutionResult

use of org.apache.maven.execution.DefaultMavenExecutionResult in project drools by kiegroup.

the class MavenEmbedder method init.

void init() throws MavenEmbedderException {
    try {
        this.mavenExecutionRequest = this.buildMavenExecutionRequest(mavenRequest);
        RepositorySystemSession rss = ((DefaultMaven) componentProvider.lookup(Maven.class)).newRepositorySession(mavenExecutionRequest);
        mavenSession = new MavenSession(componentProvider.getPlexusContainer(), rss, mavenExecutionRequest, new DefaultMavenExecutionResult());
        componentProvider.lookup(LegacySupport.class).setSession(mavenSession);
    } catch (MavenEmbedderException e) {
        log.error("Unable to build MavenEmbedder", e);
        throw e;
    } catch (ComponentLookupException e) {
        log.error("Unable to build MavenEmbedder", e);
        throw new MavenEmbedderException(e.getMessage(), e);
    }
}
Also used : RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) DefaultMaven(org.apache.maven.DefaultMaven) Maven(org.apache.maven.Maven) MavenSession(org.apache.maven.execution.MavenSession) LegacySupport(org.apache.maven.plugin.LegacySupport) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) DefaultMaven(org.apache.maven.DefaultMaven) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException)

Example 5 with DefaultMavenExecutionResult

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

the class MavenServerImpl method runMavenRequest.

public void runMavenRequest(MavenExecutionRequest request, Runnable runnable) {
    DefaultMaven maven = (DefaultMaven) getMavenComponent(Maven.class);
    RepositorySystemSession repositorySystemSession = maven.newRepositorySession(request);
    request.getProjectBuildingRequest().setRepositorySession(repositorySystemSession);
    MavenSession mavenSession = new MavenSession(container, repositorySystemSession, request, new DefaultMavenExecutionResult());
    LegacySupport legacySupport = getMavenComponent(LegacySupport.class);
    MavenSession previousSession = legacySupport.getSession();
    legacySupport.setSession(mavenSession);
    try {
        for (AbstractMavenLifecycleParticipant participant : getLifecycleParticipants(Collections.emptyList())) {
            participant.afterSessionStart(mavenSession);
        }
        runnable.run();
    } catch (MavenExecutionException e) {
        throw new RuntimeException(e);
    } finally {
        legacySupport.setSession(previousSession);
    }
}
Also used : DefaultMaven(org.apache.maven.DefaultMaven) Maven(org.apache.maven.Maven) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) MavenSession(org.apache.maven.execution.MavenSession) MavenExecutionException(org.apache.maven.MavenExecutionException) LegacySupport(org.apache.maven.plugin.LegacySupport) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) AbstractMavenLifecycleParticipant(org.apache.maven.AbstractMavenLifecycleParticipant) DefaultMaven(org.apache.maven.DefaultMaven)

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