Search in sources :

Example 11 with MavenSession

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

the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingGroupInTargetDefinition.

@Test
public void testAddTargetWithMissingGroupInTargetDefinition() {
    Xpp3Dom dom = createGavConfiguration(null, "myArtifactId", "myVersion");
    MavenSession session = setupMockSession();
    TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
    try {
        configurationReader.addTargetArtifact(configuration, session, null, dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Example 12 with MavenSession

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

the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingArtifactIdInTargetDefinition.

@Test
public void testAddTargetWithMissingArtifactIdInTargetDefinition() {
    Xpp3Dom dom = createGavConfiguration("myGroupId", null, "myVersion");
    MavenSession session = setupMockSession();
    TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
    try {
        configurationReader.addTargetArtifact(configuration, session, null, dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Example 13 with MavenSession

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

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

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

the class TychoTest method testWithValidExplicitTargetEnvironment.

public void testWithValidExplicitTargetEnvironment() throws Exception {
    File basedir = getBasedir("projects/explicitenvironment/valid");
    List<MavenProject> projects = getSortedProjects(basedir);
    assertEquals(1, projects.size());
    assertEquals("valid", projects.get(0).getArtifactId());
    DefaultTargetPlatformConfigurationReader resolver = lookup(DefaultTargetPlatformConfigurationReader.class);
    MavenSession session = newMavenSession(projects.get(0), projects);
    TargetPlatformConfiguration configuration;
    List<TargetEnvironment> environments;
    configuration = resolver.getTargetPlatformConfiguration(session, session.getCurrentProject());
    environments = configuration.getEnvironments();
    assertEquals(1, environments.size());
    TargetEnvironment env = environments.get(0);
    assertEquals("linux", env.getOs());
    assertEquals("gtk", env.getWs());
    assertEquals("arm", env.getArch());
}
Also used : DefaultTargetPlatformConfigurationReader(org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader) MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration)

Aggregations

MavenSession (org.apache.maven.execution.MavenSession)117 File (java.io.File)65 MavenProject (org.apache.maven.project.MavenProject)47 SimpleLocalRepositoryManager (org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager)30 DefaultRepositorySystemSession (org.sonatype.aether.util.DefaultRepositorySystemSession)23 Test (org.junit.Test)21 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)20 LegacySupport (org.apache.maven.plugin.LegacySupport)19 Properties (java.util.Properties)18 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)18 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)16 MojoExecution (org.apache.maven.plugin.MojoExecution)13 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)13 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)11 Artifact (org.apache.maven.artifact.Artifact)10 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)9 ManipulationSession (org.commonjava.maven.ext.core.ManipulationSession)8 MavenExecutionResult (org.apache.maven.execution.MavenExecutionResult)7 Settings (org.apache.maven.settings.Settings)7 ArrayList (java.util.ArrayList)6