use of org.eclipse.equinox.p2.metadata.IArtifactKey in project tycho by eclipse.
the class TargetPlatformBundlePublisherTest method testPomDependencyOnBundle.
@Test
public void testPomDependencyOnBundle() throws Exception {
String bundleId = "org.eclipse.osgi";
String bundleVersion = "3.5.2.R35x_v20100126";
FileUtils.copyDirectory(resourceFile("platformbuilder/pom-dependencies/bundle-repo"), localRepositoryRoot);
File bundleFile = new File(localRepositoryRoot, RepositoryLayoutHelper.getRelativePath(GROUP_ID, ARTIFACT_ID, VERSION, null, "jar"));
IArtifactFacade bundleArtifact = new ArtifactMock(bundleFile, GROUP_ID, ARTIFACT_ID, VERSION, "jar");
IInstallableUnit publishedUnit = subject.attemptToPublishBundle(bundleArtifact);
assertThat(publishedUnit, is(unit(bundleId, bundleVersion)));
assertThat(publishedUnit.getProperties(), containsGAV(GROUP_ID, ARTIFACT_ID, VERSION));
assertThat(publishedUnit.getArtifacts().size(), is(1));
IArtifactKey referencedArtifact = publishedUnit.getArtifacts().iterator().next();
IRawArtifactProvider artifactRepo = subject.getArtifactRepoOfPublishedBundles();
assertThat(artifactRepo, contains(referencedArtifact));
IArtifactDescriptor[] artifactDescriptors = artifactRepo.getArtifactDescriptors(referencedArtifact);
assertThat(artifactDescriptors.length, is(1));
assertThat(artifactDescriptors[0].getProperties(), containsGAV(GROUP_ID, ARTIFACT_ID, VERSION));
assertThat(artifactDescriptors[0].getProperties(), hasProperty("download.md5", "6303323acc98658c0fed307c84db4411"));
// test that reading the artifact succeeds (because the way it is added to the repository is a bit special)
assertThat(artifactMD5Of(referencedArtifact, artifactRepo), is("6303323acc98658c0fed307c84db4411"));
}
use of org.eclipse.equinox.p2.metadata.IArtifactKey in project tycho by eclipse.
the class FeatureRootfileArtifactRepository method createRootfileOutputStream.
private OutputStream createRootfileOutputStream(IArtifactKey artifactKey) throws ProvisionException, IOException {
File outputFile = new File(this.outputDirectory, artifactKey.getId() + "-" + artifactKey.getVersion() + "-" + ROOTFILE_CLASSIFIER + "." + ROOTFILE_EXTENSION);
OutputStream target = null;
try {
SimpleArtifactDescriptor simpleArtifactDescriptor = (SimpleArtifactDescriptor) createArtifactDescriptor(artifactKey);
Collection<IPropertyAdvice> advices = publisherInfo.getAdvice(null, false, simpleArtifactDescriptor.getArtifactKey().getId(), simpleArtifactDescriptor.getArtifactKey().getVersion(), IPropertyAdvice.class);
boolean mavenPropAdviceExists = false;
for (IPropertyAdvice entry : advices) {
if (entry instanceof MavenPropertiesAdvice) {
mavenPropAdviceExists = true;
entry.getArtifactProperties(null, simpleArtifactDescriptor);
}
}
if (!mavenPropAdviceExists) {
throw new ProvisionException("MavenPropertiesAdvice does not exist for artifact: " + simpleArtifactDescriptor);
}
String mavenArtifactClassifier = getRootFileArtifactClassifier(simpleArtifactDescriptor.getArtifactKey().getId());
simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_CLASSIFIER, mavenArtifactClassifier);
simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_EXTENSION, ROOTFILE_EXTENSION);
target = new BufferedOutputStream(new FileOutputStream(outputFile));
this.publishedArtifacts.put(mavenArtifactClassifier, new P2Artifact(outputFile, Collections.<IInstallableUnit>emptySet(), simpleArtifactDescriptor));
descriptors.add(simpleArtifactDescriptor);
} catch (FileNotFoundException e) {
throw new ProvisionException(e.getMessage(), e);
}
return target;
}
use of org.eclipse.equinox.p2.metadata.IArtifactKey in project tycho by eclipse.
the class ModuleArtifactRepositoryTest method artifactSizeOf.
private static int artifactSizeOf(IArtifactKey artifactKey, IArtifactRepository subject) {
IArtifactDescriptor[] artifactDescriptors = subject.getArtifactDescriptors(artifactKey);
assertEquals(1, artifactDescriptors.length);
ByteArrayOutputStream artifactContent = new ByteArrayOutputStream();
subject.getArtifact(artifactDescriptors[0], artifactContent, null);
return artifactContent.size();
}
use of org.eclipse.equinox.p2.metadata.IArtifactKey in project tycho by eclipse.
the class PackedFormatMirroringArtifactProvider method downloadMostSpecificNeededFormatOfArtifact.
@Override
protected IStatus downloadMostSpecificNeededFormatOfArtifact(IArtifactKey key) throws ProvisionException, ArtifactSinkException {
IArtifactDescriptor[] allDescriptors = remoteProviders.getArtifactDescriptors(key);
IArtifactDescriptor packedDescriptor = findPackedDescriptor(allDescriptors);
if (packedDescriptor != null) {
// TODO 393004 remove "maven-groupId", etc. properties to force storage as p2/osgi/bundle...
return downloadRawArtifact(packedDescriptor);
} else {
logger.debug("No remote repository provides " + key.getId() + "_" + key.getVersion() + " in packed format. Only the canonical format will be available in the build.");
return downloadCanonicalArtifact(key);
}
}
use of org.eclipse.equinox.p2.metadata.IArtifactKey in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testRemoveNonContainedKey.
@Test
public void testRemoveNonContainedKey() {
IArtifactKey keyToRemove = OTHER_KEY;
subject.removeDescriptor(keyToRemove);
assertNoChanges();
}
Aggregations