Search in sources :

Example 1 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class P2ResolverTest method testProductMultienvP2Inf.

@Test
public void testProductMultienvP2Inf() throws Exception {
    List<TargetEnvironment> environments = new ArrayList<>();
    environments.add(new TargetEnvironment("linux", "gtk", "x86_64"));
    environments.add(new TargetEnvironment("macosx", "cocoa", "x86_64"));
    impl.setEnvironments(environments);
    String artifactId = "product.multienv.p2-inf";
    projectToResolve = createReactorProject(resourceFile("resolver/product.multienv.p2-inf"), TYPE_ECLIPSE_REPOSITORY, artifactId);
    List<P2ResolutionResult> results = impl.resolveDependencies(getTargetPlatform(), projectToResolve);
    assertEquals(2, results.size());
    P2ResolutionResult linux = results.get(0);
    List<Entry> linuxEntries = new ArrayList<>(linux.getArtifacts());
    assertEquals(1, linuxEntries.size());
    assertEquals(1, linuxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, linux.getNonReactorUnits().size());
    P2ResolutionResult macosx = results.get(1);
    List<Entry> macosxEntries = new ArrayList<>(macosx.getArtifacts());
    assertEquals(1, macosxEntries.size());
    assertEquals(2, macosxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, macosx.getNonReactorUnits().size());
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) ArrayList(java.util.ArrayList) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Test(org.junit.Test)

Example 2 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class P2ResolverTest method testFeatureMultienvP2Inf.

@Test
public void testFeatureMultienvP2Inf() throws Exception {
    List<TargetEnvironment> environments = new ArrayList<>();
    environments.add(new TargetEnvironment("linux", "gtk", "x86_64"));
    environments.add(new TargetEnvironment("macosx", "cocoa", "x86_64"));
    impl.setEnvironments(environments);
    String artifactId = "feature.multienv.p2-inf";
    projectToResolve = createReactorProject(resourceFile("resolver/feature.multienv.p2-inf"), TYPE_ECLIPSE_FEATURE, artifactId);
    List<P2ResolutionResult> results = impl.resolveDependencies(getTargetPlatform(), projectToResolve);
    assertEquals(2, results.size());
    P2ResolutionResult linux = results.get(0);
    List<Entry> linuxEntries = new ArrayList<>(linux.getArtifacts());
    assertEquals(1, linuxEntries.size());
    assertEquals(1, linuxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, linux.getNonReactorUnits().size());
    P2ResolutionResult macosx = results.get(1);
    List<Entry> macosxEntries = new ArrayList<>(macosx.getArtifacts());
    assertEquals(1, macosxEntries.size());
    assertEquals(2, macosxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, macosx.getNonReactorUnits().size());
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) ArrayList(java.util.ArrayList) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Test(org.junit.Test)

Example 3 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class P2ResolverTestBase method getEnvironments.

protected static List<TargetEnvironment> getEnvironments() {
    List<TargetEnvironment> environments = new ArrayList<>();
    environments.add(new TargetEnvironment("linux", "gtk", "x86_64"));
    return environments;
}
Also used : ArrayList(java.util.ArrayList) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment)

Example 4 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class DefaultDependencyArtifactsTest method testMultiEnvironmentMetadataMerge.

@Test
public void testMultiEnvironmentMetadataMerge() {
    ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
    File location = new File("location");
    DefaultDependencyArtifacts tpA = new DefaultDependencyArtifacts();
    tpA.addArtifactFile(key, location, asSet("a"));
    DefaultDependencyArtifacts tpB = new DefaultDependencyArtifacts();
    tpB.addArtifactFile(key, location, asSet("a", "b"));
    MultiEnvironmentDependencyArtifacts tp = new MultiEnvironmentDependencyArtifacts();
    tp.addPlatform(new TargetEnvironment("a", "a", "a"), tpA);
    tp.addPlatform(new TargetEnvironment("b", "b", "b"), tpB);
    List<ArtifactDescriptor> artifacts = tp.getArtifacts();
    Assert.assertEquals(1, artifacts.size());
    Set<Object> units = artifacts.get(0).getInstallableUnits();
    Assert.assertEquals(2, units.size());
    Assert.assertTrue(units.contains("a"));
    Assert.assertTrue(units.contains("b"));
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File) MultiEnvironmentDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts) Test(org.junit.Test)

Example 5 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment 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

TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)38 Test (org.junit.Test)14 File (java.io.File)10 ArrayList (java.util.ArrayList)6 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)6 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)3 P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Properties (java.util.Properties)2 MavenSession (org.apache.maven.execution.MavenSession)2 MavenProject (org.apache.maven.project.MavenProject)2 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)2 ArtifactKey (org.eclipse.tycho.ArtifactKey)2 ReactorProject (org.eclipse.tycho.ReactorProject)2