use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class ProductDependenciesAction method addPublisherAdvice.
@Override
protected void addPublisherAdvice(IPublisherInfo publisherInfo) {
// see org.eclipse.equinox.p2.publisher.eclipse.ProductAction.createAdviceFileAdvice()
File productFileLocation = product.getLocation();
if (productFileLocation == null) {
return;
}
String id = product.getId();
Version parseVersion = Version.parseVersion(product.getVersion());
IPath basePath = new Path(productFileLocation.getParent());
// must match org.eclipse.tycho.plugins.p2.publisher.PublishProductMojo.getSourceP2InfFile(File)
final String productFileName = productFileLocation.getName();
final String p2infFilename = productFileName.substring(0, productFileName.length() - ".product".length()) + ".p2.inf";
AdviceFileAdvice advice = new AdviceFileAdvice(id, parseVersion, basePath, new Path(p2infFilename));
if (advice.containsAdvice()) {
publisherInfo.addAdvice(advice);
}
}
use of org.eclipse.equinox.p2.metadata.Version 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));
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class CompositeArtifactProviderTestBase method testContainsKey.
@Test
public void testContainsKey() {
assertTrue(subject.contains(BUNDLE_A_KEY));
assertTrue(subject.contains(BUNDLE_B_KEY));
String otherClassifier = "org.eclipse.update.feature";
Version otherVersion = Version.emptyVersion;
assertFalse(subject.contains(new ArtifactKey(otherClassifier, BUNDLE_A_KEY.getId(), BUNDLE_A_KEY.getVersion())));
assertFalse(subject.contains(new ArtifactKey(BUNDLE_A_KEY.getClassifier(), BUNDLE_A_KEY.getId(), otherVersion)));
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class LocalMetadataRepositoryTest method addInstallableUnit.
@Test
public void addInstallableUnit() throws CoreException {
File location = new File("target/metadataRepo");
LocalMetadataRepository repository = createRepository(location);
InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
iud.setId("test");
iud.setVersion(Version.parseVersion("1.0.0"));
iud.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
iud.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, "artifact");
iud.setProperty(RepositoryLayoutHelper.PROP_VERSION, "version");
InstallableUnitDescription iud2 = new MetadataFactory.InstallableUnitDescription();
iud2.setId("test2");
iud2.setVersion(Version.parseVersion("1.0.0"));
iud2.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
iud2.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, "artifact2");
iud2.setProperty(RepositoryLayoutHelper.PROP_VERSION, "version");
IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
IInstallableUnit iu2 = MetadataFactory.createInstallableUnit(iud2);
repository.addInstallableUnits(Arrays.asList(iu, iu2));
repository = (LocalMetadataRepository) loadRepository(location);
IQueryResult<IInstallableUnit> result = repository.query(QueryUtil.ALL_UNITS, monitor);
ArrayList<IInstallableUnit> allius = new ArrayList<>(result.toSet());
Assert.assertEquals(2, allius.size());
// as of e3.5.2 Collector uses HashSet internally and does not guarantee collected results order
// 3.6 IQueryResult, too, is backed by HashSet. makes no sense.
// Assert.assertEquals( iu.getId(), allius.get( 0 ).getId() );
Set<IInstallableUnit> ius = repository.getGAVs().get(RepositoryLayoutHelper.getGAV(iu.getProperties()));
Assert.assertEquals(1, ius.size());
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class BaselineServiceImpl method getBaselineUnit.
private IInstallableUnit getBaselineUnit(IQueryable<IInstallableUnit> units, String id, Version version) {
IQueryResult<IInstallableUnit> result = units.query(QueryUtil.createIUQuery(id, version), monitor);
if (result.isEmpty()) {
return null;
}
Iterator<IInstallableUnit> iterator = result.iterator();
IInstallableUnit unit = iterator.next();
if (iterator.hasNext()) {
throw new IllegalArgumentException();
}
return unit;
}
Aggregations