use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.
the class TargetDefinitionResolverExecutionEnvironmentTest method testAutoGeneratedExecutionEnvironment.
@Test
public void testAutoGeneratedExecutionEnvironment() throws Exception {
subject = targetResolverForEE("JavaSE-1.7");
TargetDefinition definition = definitionWith(new AlternatePackageProviderLocationStub());
Collection<IInstallableUnit> units = subject.resolveContent(definition).getUnits();
// expect that resolver did not included a bundle providing org.w3c.dom...
assertThat(units, not(hasItem(unit("javax.xml", "0.0.1.SNAPSHOT"))));
// ... but instead included the configured 'a.jre' IU (which is not contained in the repository)
assertThat(units, hasItem(unit("a.jre.javase", "1.7.0")));
// other "a.jre" IUs from the repository shall be filtered out
assertThat(units, not(hasItem(unitWithId("a.jre"))));
}
use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository 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.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.
the class LocalArtifactRepository method loadMaven.
private void loadMaven() {
final ArtifactsIO io = new ArtifactsIO();
TychoRepositoryIndex index = localRepoIndices.getArtifactsIndex();
for (final GAV gav : index.getProjectGAVs()) {
try {
File localArtifactFileLocation = contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS, RepositoryLayoutHelper.EXTENSION_P2_ARTIFACTS);
if (!localArtifactFileLocation.exists()) {
// if files have been manually removed from the repository, simply remove them from the index (bug 351080)
index.removeGav(gav);
} else {
final InputStream is = new FileInputStream(contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS, RepositoryLayoutHelper.EXTENSION_P2_ARTIFACTS));
try {
final Set<IArtifactDescriptor> gavDescriptors = io.readXML(is);
for (IArtifactDescriptor descriptor : gavDescriptors) {
internalAddDescriptor(descriptor);
}
} finally {
is.close();
}
}
} catch (IOException e) {
// TODO throw properly typed exception if repository cannot be loaded
e.printStackTrace();
}
}
descriptorsOnLastSave = new HashSet<IArtifactDescriptor>(descriptors);
}
use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository 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.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.
the class ModuleArtifactRepository method getInternalDescriptorForAdding.
@Override
protected ModuleArtifactDescriptor getInternalDescriptorForAdding(IArtifactDescriptor descriptor) throws IllegalArgumentException {
if (descriptor == null) {
throw new NullPointerException();
} else if (!(descriptor instanceof ModuleArtifactDescriptor) || descriptor.getRepository() != this) {
throw new IllegalArgumentException("Cannot add artifact descriptor which has not been created by this repository");
}
ModuleArtifactDescriptor internalDescriptor = (ModuleArtifactDescriptor) descriptor;
try {
MavenRepositoryCoordinates coordinates = internalDescriptor.getMavenCoordinates();
artifactsMap.addToAutomaticLocation(coordinates.getClassifier(), coordinates.getExtension());
} catch (ProvisionException e) {
// TODO 393004 Revise exception handling
throw new RuntimeException(e);
}
return internalDescriptor;
}
Aggregations