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));
}
}
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));
}
}
Aggregations