Search in sources :

Example 1 with P2GeneratorImpl

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

the class P2ResolverTestBase method prepare.

@Before
public final void prepare() throws Exception {
    fullGenerator = new P2GeneratorImpl(true);
    BuildPropertiesParserForTesting buildPropertiesReader = new BuildPropertiesParserForTesting();
    fullGenerator.setBuildPropertiesParser(buildPropertiesReader);
    dependencyGenerator = new DefaultDependencyMetadataGenerator();
    dependencyGenerator.setBuildPropertiesParser(buildPropertiesReader);
    tpConfig = new TargetPlatformConfigurationStub();
    tpFactory = resolverFactory.getTargetPlatformFactoryImpl();
}
Also used : TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) P2GeneratorImpl(org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl) BuildPropertiesParserForTesting(org.eclipse.tycho.test.util.BuildPropertiesParserForTesting) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) Before(org.junit.Before)

Example 2 with P2GeneratorImpl

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

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

Example 4 with P2GeneratorImpl

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

Aggregations

File (java.io.File)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)3 Test (org.junit.Test)3 P2GeneratorImpl (org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl)2 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)2 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)2 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)2 BuildPropertiesParserForTesting (org.eclipse.tycho.test.util.BuildPropertiesParserForTesting)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 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)1 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)1 DependencyMetadata (org.eclipse.tycho.p2.impl.publisher.DependencyMetadata)1 TargetPlatformConfigurationStub (org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub)1 Before (org.junit.Before)1