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());
}
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"));
}
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());
}
Aggregations