Search in sources :

Example 6 with DependencyMetadata

use of org.eclipse.tycho.p2.impl.publisher.DependencyMetadata in project tycho by eclipse.

the class TargetPlatformFactoryTest method createReactorProject.

private ReactorProject createReactorProject(String artifactId, String[] primaryUnitIds, String[] secondaryUnitIds) {
    // not dereferenced in the code under test, so the path doesn't need to exist
    File basedir = new File("tychotestdummy");
    ReactorProjectStub result = new ReactorProjectStub(basedir, artifactId);
    DependencyMetadata dependencyMetadata = new DependencyMetadata();
    dependencyMetadata.setMetadata(true, createUnits(primaryUnitIds));
    dependencyMetadata.setMetadata(false, createUnits(secondaryUnitIds));
    result.setDependencyMetadata(dependencyMetadata);
    return result;
}
Also used : ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) File(java.io.File)

Example 7 with DependencyMetadata

use of org.eclipse.tycho.p2.impl.publisher.DependencyMetadata in project tycho by eclipse.

the class P2DependencyGeneratorImplTest method generateDependencies.

private void generateDependencies(String testProjectId, String packagingType) throws IOException {
    File reactorProjectRoot = new File("resources/generator/" + testProjectId).getCanonicalFile();
    ArtifactMock reactorProject = new ArtifactMock(reactorProjectRoot, DEFAULT_GROUP_ID, testProjectId, DEFAULT_VERSION, packagingType, DEFAULT_CLASSIFIER);
    ArrayList<TargetEnvironment> emptyEnvironments = new ArrayList<>();
    DependencyMetadata metadata = subject.generateMetadata(reactorProject, emptyEnvironments);
    this.units = new ArrayList<>(metadata.getInstallableUnits());
    this.artifacts = new ArrayList<>(metadata.getArtifactDescriptors());
}
Also used : ArrayList(java.util.ArrayList) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File)

Example 8 with DependencyMetadata

use of org.eclipse.tycho.p2.impl.publisher.DependencyMetadata in project tycho by eclipse.

the class P2MetadataGeneratorImplTest method gav.

@Test
public void gav() throws Exception {
    P2GeneratorImpl impl = new P2GeneratorImpl(false);
    impl.setBuildPropertiesParser(new BuildPropertiesParserForTesting());
    File location = new File("resources/generator/bundle").getCanonicalFile();
    String groupId = "org.eclipse.tycho.p2.impl.test";
    String artifactId = "bundle";
    String version = "1.0.0-SNAPSHOT";
    List<TargetEnvironment> environments = new ArrayList<>();
    DependencyMetadata metadata = impl.generateMetadata(new ArtifactMock(location, groupId, artifactId, version, PackagingType.TYPE_ECLIPSE_PLUGIN), environments);
    List<IInstallableUnit> units = new ArrayList<>(metadata.getInstallableUnits());
    List<IArtifactDescriptor> artifacts = new ArrayList<>(metadata.getArtifactDescriptors());
    Assert.assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", unit.getId());
    Assert.assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    Assert.assertEquals(2, unit.getRequirements().size());
    Assert.assertEquals(1, artifacts.size());
    IArtifactDescriptor ad = artifacts.iterator().next();
    Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", ad.getArtifactKey().getId());
    Assert.assertEquals("1.0.0.qualifier", ad.getArtifactKey().getVersion().toString());
    Assert.assertEquals(groupId, ad.getProperties().get(RepositoryLayoutHelper.PROP_GROUP_ID));
    Assert.assertEquals(artifactId, ad.getProperties().get(RepositoryLayoutHelper.PROP_ARTIFACT_ID));
    Assert.assertEquals(version, ad.getProperties().get(RepositoryLayoutHelper.PROP_VERSION));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ArrayList(java.util.ArrayList) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) P2GeneratorImpl(org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl) BuildPropertiesParserForTesting(org.eclipse.tycho.test.util.BuildPropertiesParserForTesting) DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) Test(org.junit.Test)

Example 9 with DependencyMetadata

use of org.eclipse.tycho.p2.impl.publisher.DependencyMetadata 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

File (java.io.File)5 DependencyMetadata (org.eclipse.tycho.p2.impl.publisher.DependencyMetadata)4 ArrayList (java.util.ArrayList)3 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)3 TransientArtifactRepository (org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository)3 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)2 PublisherInfo (org.eclipse.equinox.p2.publisher.PublisherInfo)2 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)2 ReactorProjectStub (org.eclipse.tycho.p2.impl.test.ReactorProjectStub)2 IDependencyMetadata (org.eclipse.tycho.p2.metadata.IDependencyMetadata)2 Test (org.junit.Test)2 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 IStatus (org.eclipse.core.runtime.IStatus)1 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)1 Publisher (org.eclipse.equinox.p2.publisher.Publisher)1