Search in sources :

Example 6 with MetadataIO

use of org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO in project tycho by eclipse.

the class ModuleMetadataRepository method load.

private void load() throws ProvisionException {
    try {
        MetadataIO io = new MetadataIO();
        FileInputStream is = new FileInputStream(storage);
        units.addAll(io.readXML(is));
    } catch (IOException e) {
        String message = "I/O error while reading repository from " + storage;
        int code = ProvisionException.REPOSITORY_FAILED_READ;
        Status status = new Status(IStatus.ERROR, BUNDLE_ID, code, message, e);
        throw new ProvisionException(status);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 7 with MetadataIO

use of org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO in project tycho by eclipse.

the class ResolverDebugUtils method toDebugString.

public static String toDebugString(Collection<IInstallableUnit> ius, boolean verbose) {
    if (ius == null || ius.isEmpty()) {
        return "<empty>";
    }
    StringBuilder sb = new StringBuilder();
    if (verbose) {
        try {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            try {
                new MetadataIO().writeXML(new LinkedHashSet<>(ius), os);
            } finally {
                os.close();
            }
            sb.append(os.toString("UTF-8"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } else {
        for (IInstallableUnit iu : ius) {
            sb.append("  ").append(iu.toString()).append("\n");
        }
    }
    return sb.toString();
}
Also used : MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

MetadataIO (org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO)7 IOException (java.io.IOException)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)2 GAV (org.eclipse.tycho.p2.repository.GAV)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 LinkedHashSet (java.util.LinkedHashSet)1 ArtifactKey (org.eclipse.equinox.internal.p2.metadata.ArtifactKey)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)1 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)1 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)1 ArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor)1 ArtifactsIO (org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO)1 IP2Artifact (org.eclipse.tycho.p2.metadata.IP2Artifact)1