use of org.eclipse.equinox.internal.p2.metadata.ArtifactKey in project tycho by eclipse.
the class LocalArtifactRepositoryTest method newBundleArtifactDescriptor.
private ArtifactDescriptor newBundleArtifactDescriptor(boolean maven) {
ArtifactKey key = new ArtifactKey(PublisherHelper.OSGI_BUNDLE_CLASSIFIER, "org.eclipse.tycho.test." + (maven ? "maven" : "p2"), Version.createOSGi(1, 0, 0));
ArtifactDescriptor desc = new ArtifactDescriptor(key);
if (maven) {
desc.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
desc.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, key.getId());
desc.setProperty(RepositoryLayoutHelper.PROP_VERSION, key.getVersion().toString());
}
return desc;
}
use of org.eclipse.equinox.internal.p2.metadata.ArtifactKey in project tycho by eclipse.
the class AuthoredIUAction method perform.
@Override
@SuppressWarnings("deprecation")
public IStatus perform(IPublisherInfo info, IPublisherResult results, IProgressMonitor monitor) {
File iuFile = new File(iuProject, "p2iu.xml");
if (!iuFile.exists())
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not find the p2iu.xml file in folder " + iuProject);
try {
FileInputStream is = new FileInputStream(iuFile);
InstallableUnitDescription iuDescriptions = new MetadataIO().readOneIU(is);
tweakIU(iuDescriptions);
Set<IInstallableUnit> ius = toIUs(iuDescriptions);
results.addIUs(ius, IPublisherResult.ROOT);
IArtifactRepository repo = info.getArtifactRepository();
boolean artifactReferenced = false;
if (repo != null) {
for (IInstallableUnit iu : ius) {
Collection<IArtifactKey> associatedKeys = iu.getArtifacts();
for (IArtifactKey key : associatedKeys) {
ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, key, null);
processArtifactPropertiesAdvice(iu, ad, info);
ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP);
ad.setProperty(RepositoryLayoutHelper.PROP_EXTENSION, "zip");
repo.addDescriptor(ad);
artifactReferenced = true;
}
}
}
// and fails in many places. I tried to change the code where the failures were occurring but did not succeed.
if (!artifactReferenced && repo != null) {
IInstallableUnit iu = ((IInstallableUnit) ius.iterator().next());
ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, new ArtifactKey("binary", "generated_" + iu.getId(), iu.getVersion()), null);
processArtifactPropertiesAdvice(iu, ad, info);
ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP);
repo.addDescriptor(ad);
artifactReferenced = true;
}
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error while reading " + iuFile, e);
}
}
use of org.eclipse.equinox.internal.p2.metadata.ArtifactKey in project tycho by eclipse.
the class FeatureRootfileArtifactRepositoryTest method createArtifactDescriptor.
private ArtifactDescriptor createArtifactDescriptor(String classifier, String artifactId) {
ArtifactKey key = new ArtifactKey(classifier, artifactId, Version.createOSGi(1, 0, 0));
ArtifactDescriptor desc = new ArtifactDescriptor(key);
return desc;
}
use of org.eclipse.equinox.internal.p2.metadata.ArtifactKey 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.internal.p2.metadata.ArtifactKey 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)));
}
Aggregations