use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class LocalMetadataRepositoryTest method testOutdatedIndex.
@Test
public void testOutdatedIndex() throws CoreException {
// create and fill repo
File location = new File("target/indexmetadataRepo");
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");
IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
repository.addInstallableUnits(Arrays.asList(iu));
repository = (LocalMetadataRepository) loadRepository(location);
// check: the artifact is in the index
TychoRepositoryIndex metaIndex = createMetadataIndex(location);
Assert.assertFalse(metaIndex.getProjectGAVs().isEmpty());
// delete artifact from file system
deleteDir(new File(location, "group"));
// create a new repo and check that the reference was gracefully removed from the index
repository = (LocalMetadataRepository) loadRepository(location);
repository.save();
metaIndex = createMetadataIndex(location);
Assert.assertTrue(metaIndex.getProjectGAVs().isEmpty());
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class LocalMetadataRepository method save.
public void save() {
File basedir = new File(getLocation());
MetadataIO io = new MetadataIO();
for (GAV gav : changedGAVs) {
Set<IInstallableUnit> gavUnits = unitsMap.get(gav);
if (gavUnits != null && !gavUnits.isEmpty()) {
String relpath = RepositoryLayoutHelper.getRelativePath(gav, RepositoryLayoutHelper.CLASSIFIER_P2_METADATA, RepositoryLayoutHelper.EXTENSION_P2_METADATA);
File file = new File(basedir, relpath);
file.getParentFile().mkdirs();
try {
io.writeXML(gavUnits, file);
metadataIndex.addGav(gav);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
try {
metadataIndex.save();
} catch (IOException e) {
throw new RuntimeException(e);
}
changedGAVs.clear();
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class LocalMetadataRepository method addInstallableUnits.
@Override
public void addInstallableUnits(Collection<IInstallableUnit> newUnits) {
for (IInstallableUnit unit : newUnits) {
GAV gav = RepositoryLayoutHelper.getGAV(unit.getProperties());
addInstallableUnit(unit, gav);
}
save();
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class ReactorRepositoryManagerTest method testTargetPlatformComputationInIntegration.
@Test
public void testTargetPlatformComputationInIntegration() throws Exception {
subject = getService(ReactorRepositoryManagerFacade.class);
ReactorProject currentProject = new ReactorProjectStub("reactor-artifact");
TargetPlatformConfigurationStub tpConfig = new TargetPlatformConfigurationStub();
tpConfig.addP2Repository(new MavenRepositoryLocation(null, ResourceUtil.resourceFile("repositories/launchers").toURI()));
subject.computePreliminaryTargetPlatform(currentProject, tpConfig, new ExecutionEnvironmentConfigurationStub("JavaSE-1.7"), null, null);
ReactorProjectIdentities upstreamProject = new ReactorProjectIdentitiesStub(ResourceUtil.resourceFile("projectresult"));
subject.computeFinalTargetPlatform(currentProject, Arrays.asList(upstreamProject));
P2TargetPlatform finalTP = (P2TargetPlatform) currentProject.getContextValue("org.eclipse.tycho.core.TychoConstants/targetPlatform");
Collection<IInstallableUnit> units = finalTP.getInstallableUnits();
// units from the p2 repository
assertThat(units, hasItem(unitWithId("org.eclipse.equinox.launcher")));
// units from the upstream project
assertThat(units, hasItem(unitWithId("bundle")));
assertThat(units, hasItem(unitWithId("bundle.source")));
// TODO get artifact
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class P2GeneratorImplTest method testOptionalImportPackage_REQUIRE.
@Test
public void testOptionalImportPackage_REQUIRE() throws Exception {
DefaultDependencyMetadataGenerator generator = createDependencyMetadataGenerator();
File location = new File("resources/generator/optional-import-package").getCanonicalFile();
ArtifactMock artifactMock = new ArtifactMock(location, "optional-import-package", "optional-import-package", "0.0.1", "eclipse-plugin");
Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.REQUIRE).getMetadata();
assertEquals(1, units.size());
IInstallableUnit iu = getUnit("optional-import-package", units);
assertNotNull(iu);
List<IRequirement> requirements = new ArrayList<>(iu.getRequirements());
assertEquals(1, requirements.size());
IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
assertTrue(requirement.isGreedy());
assertEquals(1, requirement.getMin());
assertEquals(1, requirement.getMax());
assertEquals(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, requirement.getNamespace());
assertEquals("org.osgi.framework", requirement.getName());
}
Aggregations