use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.
the class GAVArtifactDescriptorTest method testDeserialization.
@Test
public void testDeserialization() {
// parsing to p2's implementation of IArtifactDescriptor is done elsewhere, so assume this is the input
ArtifactDescriptor input = createP2Descriptor();
input.setProperty("maven-groupId", TEST_GAV.getGroupId());
input.setProperty("maven-artifactId", TEST_GAV.getArtifactId());
input.setProperty("maven-version", TEST_GAV.getVersion());
subject = new GAVArtifactDescriptor(input);
assertThat(subject.getArtifactKey(), is(TEST_KEY));
assertThat(subject.getMavenCoordinates(), is(new MavenRepositoryCoordinates(TEST_GAV, DEFAULT_CLASSIFIER, DEFAULT_EXTENSION)));
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testRemoveForeignEquivalentDescriptor.
@Test
public void testRemoveForeignEquivalentDescriptor() {
IArtifactDescriptor foreignDescriptor = foreignEquivalentOf(ARTIFACT_B_DESCRIPTOR);
// self-test
assertTrue(subject.contains(foreignDescriptor));
subject.removeDescriptor(foreignDescriptor);
// foreign descriptor must have been replaced by internal descriptor for the calls to the internal HashMap
assertFalse(subject.contains(foreignDescriptor));
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method localPackedDescriptorFor.
/**
* Returns a descriptor of the internally used {@link IArtifactDescriptor} type for the pack200
* format of the given key.
*/
private static IArtifactDescriptor localPackedDescriptorFor(IArtifactKey key) {
GAVArtifactDescriptor result = new GAVArtifactDescriptor(key);
result.setProcessingSteps(new IProcessingStepDescriptor[] { new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true) });
result.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED);
return result;
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.
the class LocalArtifactRepository method saveMaven.
private void saveMaven() {
File location = getBasedir();
TychoRepositoryIndex index = localRepoIndices.getArtifactsIndex();
ArtifactsIO io = new ArtifactsIO();
Set<IArtifactDescriptor> changedDescriptors = new HashSet<IArtifactDescriptor>(descriptors);
changedDescriptors.removeAll(descriptorsOnLastSave);
Set<IArtifactKey> changedKeys = new HashSet<>();
for (IArtifactDescriptor changedDescriptor : changedDescriptors) {
changedKeys.add(changedDescriptor.getArtifactKey());
}
for (IArtifactKey key : changedKeys) {
Set<GAVArtifactDescriptor> keyDescriptors = descriptorsMap.get(key);
if (keyDescriptors != null && !keyDescriptors.isEmpty()) {
// all descriptors should have the same GAV
GAVArtifactDescriptor anyDescriptorOfKey = keyDescriptors.iterator().next();
GAV gav = anyDescriptorOfKey.getMavenCoordinates().getGav();
index.addGav(gav);
String relpath = getMetadataRelpath(gav);
File file = new File(location, relpath);
file.getParentFile().mkdirs();
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
try {
io.writeXML(keyDescriptors, os);
} finally {
os.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
try {
index.save();
} catch (IOException e) {
throw new RuntimeException(e);
}
descriptorsOnLastSave = new HashSet<IArtifactDescriptor>(descriptors);
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor 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);
}
Aggregations