@Test
  public void testMultiEnvironmentMetadataMerge() {
    ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
    File location = new File("location");

    DefaultTargetPlatform tpA = new DefaultTargetPlatform();
    tpA.addArtifactFile(key, location, asSet("a"));

    DefaultTargetPlatform tpB = new DefaultTargetPlatform();
    tpB.addArtifactFile(key, location, asSet("a", "b"));

    MultiEnvironmentTargetPlatform tp = new MultiEnvironmentTargetPlatform();

    tp.addPlatform(new TargetEnvironment("a", "a", "a", "a"), tpA);
    tp.addPlatform(new TargetEnvironment("b", "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"));
  }
  protected DependencyArtifacts doResolvePlatform(
      final MavenSession session,
      final MavenProject project,
      List<ReactorProject> reactorProjects,
      DependencyResolverConfiguration resolverConfiguration,
      TargetPlatform resolutionContext,
      P2Resolver resolver,
      TargetPlatformConfiguration configuration) {

    Map<File, ReactorProject> projects = new HashMap<File, ReactorProject>();

    resolver.setEnvironments(getEnvironments(configuration));

    for (ReactorProject otherProject : reactorProjects) {
      projects.put(otherProject.getBasedir(), otherProject);
    }

    if (resolverConfiguration != null) {
      for (Dependency dependency : resolverConfiguration.getExtraRequirements()) {
        resolver.addDependency(
            dependency.getType(), dependency.getArtifactId(), dependency.getVersion());
      }
    }

    if (!isAllowConflictingDependencies(project, configuration)) {
      List<P2ResolutionResult> results =
          resolver.resolveProject(resolutionContext, project.getBasedir());

      MultiEnvironmentTargetPlatform multiPlatform =
          new MultiEnvironmentTargetPlatform(DefaultReactorProject.adapt(project));

      // FIXME this is just wrong
      for (int i = 0; i < configuration.getEnvironments().size(); i++) {
        TargetEnvironment environment = configuration.getEnvironments().get(i);
        P2ResolutionResult result = results.get(i);

        DefaultTargetPlatform platform =
            newDefaultTargetPlatform(
                session, DefaultReactorProject.adapt(project), projects, result);

        // addProjects( session, platform );

        multiPlatform.addPlatform(environment, platform);
      }

      return multiPlatform;
    } else {
      P2ResolutionResult result =
          resolver.collectProjectDependencies(resolutionContext, project.getBasedir());

      return newDefaultTargetPlatform(
          session, DefaultReactorProject.adapt(project), projects, result);
    }
  }