Search in sources :

Example 1 with SourcesBundleDependencyMetadataGenerator

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

the class P2ResolverTest method testSourceBundle.

@Test
public void testSourceBundle() throws Exception {
    String featureId = "org.eclipse.tycho.p2.impl.resolver.test.feature01";
    projectToResolve = createReactorProject(resourceFile("sourcebundles/feature01"), TYPE_ECLIPSE_FEATURE, featureId);
    File bundle = resourceFile("sourcebundles/bundle01");
    String bundleId = "org.eclipse.tycho.p2.impl.resolver.test.bundle01";
    String bundleVersion = "1.0.0-SNAPSHOT";
    reactorProjects.add(createReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, bundleId));
    ReactorProjectStub sb = new ReactorProjectStub(bundle, bundleId, bundleId, bundleVersion, TYPE_ECLIPSE_PLUGIN);
    DependencyMetadata metadata = new SourcesBundleDependencyMetadataGenerator().generateMetadata(new ArtifactMock(sb, "source"), getEnvironments(), null);
    sb.setDependencyMetadata(metadata);
    reactorProjects.add(sb);
    result = singleEnv(impl.resolveDependencies(getTargetPlatform(), projectToResolve));
    assertEquals(3, result.getArtifacts().size());
    List<P2ResolutionResult.Entry> entries = new ArrayList<>(result.getArtifacts());
    Collections.sort(entries, new Comparator<Entry>() {

        @Override
        public int compare(Entry entry1, Entry entry2) {
            return entry1.getId().compareTo(entry2.getId());
        }
    });
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01", entries.get(0).getId());
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01.source", entries.get(1).getId());
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.feature01", entries.get(2).getId());
    assertEquals(bundle, entries.get(0).getLocation());
    assertEquals(bundle, entries.get(1).getLocation());
    assertEquals("sources", entries.get(1).getClassifier());
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) ArrayList(java.util.ArrayList) DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) Test(org.junit.Test)

Example 2 with SourcesBundleDependencyMetadataGenerator

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

the class P2GeneratorImplTest method testGenerateSourceBundleMetadata.

@Test
public void testGenerateSourceBundleMetadata() throws Exception {
    DependencyMetadataGenerator p2GeneratorImpl = new SourcesBundleDependencyMetadataGenerator();
    File location = new File("resources/generator/bundle").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "org.acme", "foo", "0.0.1", "eclipse-plugin");
    Set<Object> units = p2GeneratorImpl.generateMetadata(artifactMock, getEnvironments(), null).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit sourceBundleUnit = getUnit("foo.source", units);
    assertNotNull(sourceBundleUnit);
    assertEquals(Version.create("0.0.1"), sourceBundleUnit.getVersion());
    assertThat(sourceBundleUnit, hasGAV("org.acme", "foo", "0.0.1", "sources"));
    ITouchpointData touchPointData = sourceBundleUnit.getTouchpointData().iterator().next();
    String manifestContent = touchPointData.getInstruction("manifest").getBody();
    Manifest manifest = new Manifest(new ByteArrayInputStream(manifestContent.getBytes("UTF-8")));
    Attributes attributes = manifest.getMainAttributes();
    assertEquals("foo.source", attributes.getValue("Bundle-SymbolicName"));
// assertEquals("foo;version=0.0.1;roots:=\".\"", attributes.getValue("Eclipse-SourceBundle"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Attributes(java.util.jar.Attributes) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ITouchpointData(org.eclipse.equinox.p2.metadata.ITouchpointData) Manifest(java.util.jar.Manifest) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Example 3 with SourcesBundleDependencyMetadataGenerator

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

the class P2GeneratorImplTest method generateSourceBundleMetadataForProjectWithP2Inf.

@Test
public void generateSourceBundleMetadataForProjectWithP2Inf() throws Exception {
    // p2.inf must not leak into sources bundle
    DependencyMetadataGenerator p2GeneratorImpl = new SourcesBundleDependencyMetadataGenerator();
    File location = new File("resources/generator/bundle-p2-inf").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "org.acme", "foo", "0.0.1", "eclipse-plugin");
    Set<Object> units = p2GeneratorImpl.generateMetadata(artifactMock, getEnvironments(), null).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit unit = getUnit("foo.source", units);
    assertEquals(0, unit.getRequirements().size());
}
Also used : ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Aggregations

File (java.io.File)3 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)3 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)3 Test (org.junit.Test)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)2 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 Attributes (java.util.jar.Attributes)1 Manifest (java.util.jar.Manifest)1 ITouchpointData (org.eclipse.equinox.p2.metadata.ITouchpointData)1 DependencyMetadata (org.eclipse.tycho.p2.impl.publisher.DependencyMetadata)1 ReactorProjectStub (org.eclipse.tycho.p2.impl.test.ReactorProjectStub)1 ResourceUtil.resourceFile (org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile)1 Entry (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1