use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class JpmRepoTest method testUnresolved.
public void testUnresolved() throws ResolutionException {
Repository repo = ws.getPlugin(Repository.class);
BndEditModel model = new BndEditModel();
model.setRunFw("org.apache.felix.framework");
List<Requirement> requires = new ArrayList<Requirement>();
CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.webconsole", "[4,5)");
requires.add(capReq.buildSyntheticRequirement());
Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires);
assertNotNull(shell);
assertEquals(1, shell.size());
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, ws, log);
Resolver resolver = new BndResolver(new org.apache.felix.resolver.Logger(4));
try {
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
fail("Resolve did not fail");
} catch (ResolutionException e) {
assertEquals(1, e.getUnresolvedRequirements().size());
ResolutionException augmented = ResolveProcess.augment(context, e);
assertEquals(2, augmented.getUnresolvedRequirements().size());
}
}
use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class GenericResolveContextResolveTest method testSimpleResolve.
/**
* Simple basic resolve. We use a small index with gogo + framework and then
* try to see if we can resolve the runtime from the shell requirement.
*
* @throws Exception
*/
public void testSimpleResolve() throws Exception {
Repository repository = createRepo(IO.getFile("testdata/repo3.index.xml"));
GenericResolveContext grc = new GenericResolveContext(logger);
grc.setLevel(2);
grc.addRepository(repository);
grc.addFramework("org.apache.felix.framework", null);
grc.addEE(EE.JavaSE_1_7);
grc.addRequireBundle("org.apache.felix.gogo.shell", new VersionRange("[0,1]"));
grc.done();
Resolver resolver = new BndResolver(new ResolverLogger(4));
Set<Resource> resources = resolver.resolve(grc).keySet();
assertNotNull(getResource(resources, "org.apache.felix.gogo.runtime", "0.10"));
}
use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class DebugReporter method resource.
private void resource(Resource r) {
IdentityCapability id = ResourceUtils.getIdentityCapability(r);
String resolveError = null;
if (!context.isSystemResource(r) && level >= 3 && id != null)
try {
String v = id.version() == null ? null : id.version().toString();
Requirement req = CapReqBuilder.createBundleRequirement(id.osgi_identity(), v).buildSyntheticRequirement();
context.setInputRequirements(req);
Resolver resolver = new BndResolver(new ResolverLogger(4));
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
} catch (Exception e) {
resolveError = e.toString();
}
String s = resolveError == null ? " " : "!";
if (id == null)
out.printf("%s %s%n", s, r);
else
out.printf("%s %-50s %-20s %s%n", s, id.osgi_identity(), noNull(id.version()), id.description(""));
if (level >= 2) {
for (Capability c : r.getCapabilities(null)) {
capability(" ", c);
}
for (Requirement rq : r.getRequirements(null)) {
requirement(" ", rq);
}
}
}
use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class JpmRepoTest method testSimpleResolve.
// public void testResolveProviderWithRunpath() throws Exception {
// try {
// Project provider = ws.getProject("provider");
// provider.build();
// assertTrue(provider.check());
//
// Project requirer = ws.getProject("requirer");
// requirer.build();
// assertTrue(requirer.check());
//
// BndEditModel model = new BndEditModel();
// model.setProject(requirer);
// BndrunResolveContext context = new BndrunResolveContext(model, ws, log);
//
// Resolver resolver = new ResolverImpl(new
// org.apache.felix.resolver.Logger(4), null);
//
// Map<Resource,List<Wire>> resolved = resolver.resolve(context);
// Set<Resource> resources = resolved.keySet();
// Resource resource = getResource(resources, "requirer", "0");
// assertNotNull(resource);
// }
// catch (ResolutionException e) {
// fail("Resolve failed " + e);
// }
// }
public void testSimpleResolve() {
Repository repo = ws.getPlugin(Repository.class);
BndEditModel model = new BndEditModel();
model.setRunFw("org.apache.felix.framework");
List<Requirement> requires = new ArrayList<Requirement>();
CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.gogo.shell", "[0,1)");
requires.add(capReq.buildSyntheticRequirement());
Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires);
assertNotNull(shell);
assertEquals(1, shell.size());
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, ws, log);
Resolver resolver = new BndResolver(new org.apache.felix.resolver.Logger(4));
try {
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
Set<Resource> resources = resolved.keySet();
Resource resource = getResource(resources, "org.apache.felix.gogo.runtime", "0.12");
assertNotNull(resource);
} catch (ResolutionException e) {
fail("Resolve failed");
}
}
use of org.osgi.service.resolver.Resolver in project aries by apache.
the class DependencyCalculator method calculateDependencies.
public List<Requirement> calculateDependencies() throws ResolutionException {
ArrayList<Requirement> result = new ArrayList<Requirement>();
Resolver resolver = Activator.getInstance().getResolver();
Map<Resource, List<Wire>> resolution = resolver.resolve(context);
for (List<Wire> wires : resolution.values()) for (Wire wire : wires) if (wire.getCapability() instanceof MissingCapability)
result.add(wire.getRequirement());
result.trimToSize();
return result;
}
Aggregations