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);
}
use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.
the class ResolveTest method testSimpleResolve.
/**
* This is a basic test of resolving. This test is paired with
* {@link #testResolveWithDistro()}. If you change the resources, make sure
* this is done in the same way. The {@link #testResolveWithDistro()} has a
* negative check while this one checks positive.
*/
public void testSimpleResolve() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
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());
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
Resolver resolver = new BndResolver(new ResolverLogger(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.10");
assertNotNull(resource);
} catch (ResolutionException e) {
fail("Resolve failed");
}
}
use of aQute.bnd.build.model.BndEditModel in project bndtools by bndtools.
the class ExportPatternsListPart method getProject.
Project getProject() {
Project project = null;
try {
BndEditModel model = (BndEditModel) getManagedForm().getInput();
File bndFile = model.getBndResource();
IPath path = Central.toPath(bndFile);
IFile resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
project = Central.getProject(resource.getProject());
} catch (Exception e) {
logger.logError("Error getting project from editor model", e);
}
return project;
}
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;
}
Aggregations