Search in sources :

Example 1 with DefaultReactorProject

use of org.eclipse.tycho.core.osgitools.DefaultReactorProject in project tycho by eclipse.

the class DefaultDependencyArtifactsTest method testDoNotCacheArtifactsThatRepresentReactorProjects.

@Test
public void testDoNotCacheArtifactsThatRepresentReactorProjects() {
    // IInstallableUnit #hashCode and #equals methods only use (version,id) tuple to determine IU equality
    // Reactor projects are expected to produce different IUs potentially with the same (version,id) during the build
    // This test verifies that different DefaultTargetPlatform can have the same reactor project with different IUs
    // even when IUs (version,id) are the same
    ReactorProject project = new DefaultReactorProject(new MavenProject());
    ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
    File location = new File("location");
    DefaultDependencyArtifacts tp1 = new DefaultDependencyArtifacts();
    tp1.addArtifact(new DefaultArtifactDescriptor(key, location, project, null, asSet(new FunnyEquals("id", "a"))));
    DefaultDependencyArtifacts tp2 = new DefaultDependencyArtifacts();
    tp2.addArtifact(new DefaultArtifactDescriptor(key, location, project, null, asSet(new FunnyEquals("id", "b"))));
    // 
    Assert.assertEquals(// 
    "a", ((FunnyEquals) tp1.getArtifact(location).get(null).getInstallableUnits().iterator().next()).getData());
    // 
    Assert.assertEquals(// 
    "b", ((FunnyEquals) tp2.getArtifact(location).get(null).getInstallableUnits().iterator().next()).getData());
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) MavenProject(org.apache.maven.project.MavenProject) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) File(java.io.File) Test(org.junit.Test)

Example 2 with DefaultReactorProject

use of org.eclipse.tycho.core.osgitools.DefaultReactorProject in project tycho by eclipse.

the class P2DependencyResolver method getThisReactorProject.

private ReactorProject getThisReactorProject(MavenSession session, MavenProject project, TargetPlatformConfiguration configuration) {
    // 'this' project should obey optionalDependencies configuration
    final List<TargetEnvironment> environments = configuration.getEnvironments();
    final OptionalResolutionAction optionalAction = configuration.getDependencyResolverConfiguration().getOptionalResolutionAction();
    Map<String, IDependencyMetadata> dependencyMetadata = getDependencyMetadata(session, project, environments, optionalAction);
    final Set<Object> metadata = new LinkedHashSet<>();
    final Set<Object> secondaryMetadata = new LinkedHashSet<>();
    for (Map.Entry<String, IDependencyMetadata> entry : dependencyMetadata.entrySet()) {
        metadata.addAll(entry.getValue().getMetadata(true));
        secondaryMetadata.addAll(entry.getValue().getMetadata(false));
    }
    ReactorProject reactorProjet = new DefaultReactorProject(project) {

        @Override
        public Set<?> getDependencyMetadata(boolean primary) {
            return primary ? metadata : secondaryMetadata;
        }
    };
    return reactorProjet;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) OptionalResolutionAction(org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ReactorProject (org.eclipse.tycho.ReactorProject)2 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)2 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 MavenProject (org.apache.maven.project.MavenProject)1 ArtifactKey (org.eclipse.tycho.ArtifactKey)1 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)1 DefaultArtifactDescriptor (org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor)1 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)1 OptionalResolutionAction (org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction)1 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)1 IDependencyMetadata (org.eclipse.tycho.p2.metadata.IDependencyMetadata)1 Test (org.junit.Test)1