use of org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO 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.tycho.p2.maven.repository.xmlio.MetadataIO in project tycho by eclipse.
the class AbstractMavenMetadataRepository method load.
protected void load() {
MetadataIO io = new MetadataIO();
for (GAV gav : metadataIndex.getProjectGAVs()) {
try {
File localArtifactFileLocation = contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_METADATA, RepositoryLayoutHelper.EXTENSION_P2_METADATA);
if (!localArtifactFileLocation.exists()) {
// if files have been manually removed from the repository, simply remove them from the index (bug 351080)
metadataIndex.removeGav(gav);
} else {
InputStream is = new FileInputStream(localArtifactFileLocation);
try {
Set<IInstallableUnit> gavUnits = io.readXML(is);
unitsMap.put(gav, gavUnits);
units.addAll(gavUnits);
} finally {
is.close();
}
}
} catch (IOException e) {
// TODO throw properly typed exception if repository cannot be loaded
e.printStackTrace();
}
}
}
use of org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO 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.tycho.p2.maven.repository.xmlio.MetadataIO in project tycho by eclipse.
the class P2GeneratorImpl method persistMetadata.
@Override
public void persistMetadata(Map<String, IP2Artifact> metadata, File unitsXml, File artifactsXml) throws IOException {
Set<IInstallableUnit> units = new LinkedHashSet<>();
Set<IArtifactDescriptor> artifactDescriptors = new LinkedHashSet<>();
for (IP2Artifact artifact : metadata.values()) {
for (Object unit : artifact.getInstallableUnits()) {
units.add((IInstallableUnit) unit);
}
artifactDescriptors.add((IArtifactDescriptor) artifact.getArtifactDescriptor());
}
new MetadataIO().writeXML(units, unitsXml);
new ArtifactsIO().writeXML(artifactDescriptors, artifactsXml);
}
use of org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO in project tycho by eclipse.
the class ModuleMetadataRepository method storeWithoutExceptionHandling.
private void storeWithoutExceptionHandling() throws IOException {
storage.getParentFile().mkdirs();
MetadataIO io = new MetadataIO();
io.writeXML(units, storage);
}
Aggregations