use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.
the class BndrunResolveContextTest method testBasicFindProviders.
public static void testBasicFindProviders() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml")));
BndEditModel runModel = new BndEditModel();
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Requirement req = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(osgi.wiring.package=org.apache.felix.gogo.api)").buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(1, providers.size());
Resource resource = providers.get(0).getResource();
assertEquals(IO.getFile("testdata/repo1/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
}
use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.
the class BndrunResolveContextTest method testDontResolveBuildOnlyLibraries.
public static void testDontResolveBuildOnlyLibraries() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/buildrepo.index.xml")));
BndEditModel runModel = new BndEditModel();
BndrunResolveContext context;
context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers1 = context.findProviders(CapReqBuilder.createPackageRequirement("org.osgi.framework", null).buildSyntheticRequirement());
assertEquals(0, providers1.size());
context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers2 = context.findProviders(CapReqBuilder.createPackageRequirement("java.security", null).buildSyntheticRequirement());
assertEquals(0, providers2.size());
}
use of aQute.bnd.build.model.BndEditModel in project bndtools by bndtools.
the class EnrouteProjectTemplate method generateBndFile.
private Resource generateBndFile(String projectName, String pkg) {
BndEditModel model = new BndEditModel();
model.setPrivatePackages(Arrays.asList(new String[] { pkg + ".provider" }));
model.setExportedPackages(Arrays.asList(new ExportedPackage(projectName + ".api", new Attrs())));
model.setBundleDescription("${warning:please explain what this bundle does}");
model.setBundleVersion("1.0.0.${tstamp}");
List<VersionedClause> buildPath = new ArrayList<VersionedClause>();
List<VersionedClause> tmp;
tmp = model.getBuildPath();
if (tmp != null)
buildPath.addAll(tmp);
Attrs attrs = new Attrs();
attrs.put("version", "@1.0");
buildPath.add(new VersionedClause("osgi.enroute.base.api", attrs));
buildPath.add(new VersionedClause("osgi.enroute.base.junit", attrs));
model.setBuildPath(buildPath);
Document doc = new Document("");
model.saveChangesTo(doc);
StringResource bndBndResource = new StringResource(doc.get());
return bndBndResource;
}
use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.
the class JpmRepoTest method testScr.
public void testScr() {
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.createSimpleRequirement("osgi.extender", "osgi.component", "[1.1,2)");
requires.add(capReq.buildSyntheticRequirement());
Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires);
assertNotNull(shell);
assertEquals(1, shell.size());
}
use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.
the class ResolveTest method testResolveWithDistro.
/**
* Test if we can resolve with a distro
*
* @throws ResolutionException
*/
public void testResolveWithDistro() throws ResolutionException {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel model = new BndEditModel();
model.setDistro(Arrays.asList("testdata/distro.jar;version=file"));
List<Requirement> requires = new ArrayList<Requirement>();
CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.gogo.shell", "[0,1)");
requires.add(capReq.buildSyntheticRequirement());
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
context.setLevel(0);
context.init();
Resolver resolver = new BndResolver(new ResolverLogger(4));
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
Set<Resource> resources = resolved.keySet();
Resource shell = getResource(resources, "org.apache.felix.gogo.shell", "0.10.0");
assertNotNull(shell);
}
Aggregations