Search in sources :

Example 1 with TargetBundle

use of org.eclipse.pde.core.target.TargetBundle in project bndtools by bndtools.

the class RepositoryTargetLocation method resolveBundles.

@Override
protected TargetBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
    resolveRepository();
    try {
        List<TargetBundle> bundles = new ArrayList<>();
        List<String> bsns = repository.list("*");
        monitor.beginTask("Resolving Bundles", bsns.size());
        int i = 0;
        for (String bsn : bsns) {
            Version version = repository.versions(bsn).last();
            File download = repository.get(bsn, version, new HashMap<String, String>(), new RepositoryPlugin.DownloadListener[] {});
            try {
                bundles.add(new TargetBundle(download));
            } catch (Exception e) {
                throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "Invalid plugin in repository: " + bsn + " @ " + getLocation(false), e));
            }
            if (monitor.isCanceled())
                return null;
            monitor.worked(++i);
        }
        monitor.done();
        return bundles.toArray(new TargetBundle[0]);
    } catch (CoreException e) {
        throw e;
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, MESSAGE_UNABLE_TO_RESOLVE_BUNDLES, e));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ArrayList(java.util.ArrayList) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) CoreException(org.eclipse.core.runtime.CoreException) TargetBundle(org.eclipse.pde.core.target.TargetBundle) CoreException(org.eclipse.core.runtime.CoreException) Version(aQute.bnd.version.Version) File(java.io.File)

Example 2 with TargetBundle

use of org.eclipse.pde.core.target.TargetBundle in project bndtools by bndtools.

the class RunDescriptorTargetLocation method resolveBundles.

@Override
protected TargetBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
    resolveBndrunFile();
    Workspace workspace;
    try {
        workspace = Central.getWorkspace();
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, MESSAGE_UNABLE_TO_LOCATE_WORKSPACE, e));
    }
    try (Bndrun bndRun = new Bndrun(workspace, bndrunFile.getRawLocation().makeAbsolute().toFile())) {
        Collection<Container> containers = bndRun.getRunbundles();
        List<TargetBundle> bundles = new ArrayList<>(containers.size());
        monitor.beginTask("Resolving Bundles", containers.size());
        int i = 0;
        for (Container container : containers) {
            try {
                bundles.add(new TargetBundle(container.getFile()));
            } catch (Exception e) {
                throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "Invalid plugin in run descriptor: " + container.getBundleSymbolicName() + " @ " + getLocation(false), e));
            }
            if (monitor.isCanceled())
                return null;
            monitor.worked(++i);
        }
        monitor.done();
        return bundles.toArray(new TargetBundle[0]);
    } catch (CoreException e) {
        throw e;
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, MESSAGE_UNABLE_TO_RESOLVE_BUNDLES, e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Container(aQute.bnd.build.Container) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) Bndrun(biz.aQute.resolve.Bndrun) IWorkspace(org.eclipse.core.resources.IWorkspace) Workspace(aQute.bnd.build.Workspace) TargetBundle(org.eclipse.pde.core.target.TargetBundle)

Aggregations

ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 TargetBundle (org.eclipse.pde.core.target.TargetBundle)2 Container (aQute.bnd.build.Container)1 Workspace (aQute.bnd.build.Workspace)1 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 Version (aQute.bnd.version.Version)1 Bndrun (biz.aQute.resolve.Bndrun)1 File (java.io.File)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1