use of biz.aQute.resolve.ResolverLogger in project bnd by bndtools.
the class DistroCommandTest method testResolveAgainstDistro.
public void testResolveAgainstDistro() throws Exception {
bnd bnd = new bnd();
CommandLine cmdline = new CommandLine(null);
List<String> remoteArgs = new ArrayList<>();
RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
File distro = new File("generated/tmp/test.distro.jar");
List<String> distroArgs = new ArrayList<>();
distroArgs.add("-o");
distroArgs.add(distro.getPath());
distroArgs.add("test.distro");
distroArgs.add("1.0.0");
DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
assertTrue(distro.exists());
ResolveProcess process = new ResolveProcess();
ResolverLogger logger = new ResolverLogger();
MockRegistry registry = new MockRegistry();
Processor model = new Processor();
model.setProperty("-distro", distro.getAbsolutePath() + ";version=file");
model.setProperty("-runfw", "org.eclipse.osgi");
model.setProperty("-runrequires", "osgi.wiring.package;filter:='(osgi.wiring.package=com.liferay.dynamic.data.mapping.taglib.servlet.taglib)'");
Map<Resource, List<Wire>> requiredResources = process.resolveRequired(model, null, registry, new BndResolver(logger), Collections.<ResolutionCallback>emptyList(), logger);
assertEquals(1, requiredResources.size());
}
use of biz.aQute.resolve.ResolverLogger in project bndtools by bndtools.
the class ResolveOperation method run.
@Override
public void run(IProgressMonitor monitor) {
MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, Messages.ResolveOperation_errorOverview, null);
// Start a coordination
BundleContext bc = Plugin.getDefault().getBundleContext();
ServiceReference<Coordinator> coordSvcRef = bc.getServiceReference(Coordinator.class);
Coordinator coordinator = coordSvcRef != null ? (Coordinator) bc.getService(coordSvcRef) : null;
Coordination coordination = coordinator != null ? coordinator.begin(ResolveOperation.class.getName(), 0) : null;
// Begin resolve
try (ResolverLogger logger = new ResolverLogger()) {
try {
ResolveProcess resolve = new ResolveProcess();
BndResolver bndResolver = new BndResolver(logger);
ReporterLogService log = new ReporterLogService(model.getWorkspace());
Map<Resource, List<Wire>> wirings = resolve.resolveRequired(model, model.getWorkspace(), bndResolver, callbacks, log);
Map<Resource, List<Wire>> optionalResources = new HashMap<Resource, List<Wire>>(resolve.getOptionalResources().size());
for (Resource optional : resolve.getOptionalResources()) {
optionalResources.put(optional, new ArrayList<Wire>(resolve.getOptionalReasons(optional)));
}
result = new ResolutionResult(Outcome.Resolved, wirings, optionalResources, null, status, logger.getLog());
if (coordination != null)
coordination.end();
} catch (ResolveCancelledException e) {
result = new ResolutionResult(Outcome.Cancelled, null, null, null, status, logger.getLog());
if (coordination != null)
coordination.fail(e);
} catch (ResolutionException e) {
status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, e.getLocalizedMessage(), e));
result = new ResolutionResult(Outcome.Unresolved, null, null, e, status, logger.getLog());
if (coordination != null)
coordination.fail(e);
} catch (Exception e) {
status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Exception during resolution.", e));
result = new ResolutionResult(Outcome.Error, null, null, null, status, logger.getLog());
if (coordination != null)
coordination.fail(e);
} finally {
if (coordinator != null)
bc.ungetService(coordSvcRef);
}
}
}
Aggregations