use of aQute.bnd.build.model.clauses.ExportedPackage in project bnd by bndtools.
the class ResolveTest method testMultipleOptionsNotDuplicated.
/**
* Simple test that resolves a requirement
*
* @throws ResolutionException
*/
public void testMultipleOptionsNotDuplicated() throws ResolutionException {
// Resolve against repo 5
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo5/index.xml"), "Test-5"));
// Set up a simple Java 7 Felix requirement as per Issue #971
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework;version='4.2.1'");
runModel.setEE(EE.JavaSE_1_7);
runModel.setSystemPackages(Collections.singletonList(new ExportedPackage("org.w3c.dom.traversal", null)));
runModel.setGenericString("-resolve.effective", "active");
// Require the log service, GoGo shell and GoGo commands
List<Requirement> requirements = new ArrayList<Requirement>();
requirements.add(new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=org.apache.felix.log)").buildSyntheticRequirement());
requirements.add(new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=org.apache.felix.gogo.shell)").buildSyntheticRequirement());
requirements.add(new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=org.apache.felix.gogo.command)").buildSyntheticRequirement());
runModel.setRunRequires(requirements);
// Resolve the bndrun
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Resolver resolver = new BndResolver(new org.apache.felix.resolver.Logger(4));
Collection<Resource> resolvedResources = new ResolveProcess().resolveRequired(runModel, registry, resolver, Collections.<ResolutionCallback>emptyList(), log).keySet();
Map<String, Resource> mandatoryResourcesBySymbolicName = new HashMap<String, Resource>();
for (Resource r : resolvedResources) {
Capability cap = r.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0);
// We shouldn't have more than one match for each symbolic name for
// this resolve
String symbolicName = (String) cap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE);
assertNull("Multiple results for " + symbolicName, mandatoryResourcesBySymbolicName.put(symbolicName, r));
}
assertEquals(4, resolvedResources.size());
}
use of aQute.bnd.build.model.clauses.ExportedPackage in project bnd by bndtools.
the class BndrunResolveContextTest method testResolveSystemPackagesExtra.
public static void testResolveSystemPackagesExtra() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
runModel.setEE(EE.JavaSE_1_6);
runModel.setSystemPackages(Collections.singletonList(new ExportedPackage("sun.reflect", new Attrs())));
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Requirement req = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(osgi.wiring.package=sun.reflect)").buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(1, providers.size());
assertEquals(IO.getFile("testdata/repo3/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
use of aQute.bnd.build.model.clauses.ExportedPackage in project bndtools by bndtools.
the class ExportPatternsListPart method selectPackagesToAdd.
protected List<ExportedPackage> selectPackagesToAdd() {
List<ExportedPackage> added = null;
final IPackageFilter filter = new IPackageFilter() {
@Override
public boolean select(String packageName) {
if (packageName.equals("java") || packageName.startsWith("java."))
return false;
return true;
}
};
IFormPage page = (IFormPage) getManagedForm().getContainer();
IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow();
// Prepare the package lister from the Java project
IProject project = ResourceUtil.getResource(page.getEditorInput()).getProject();
IJavaProject javaProject = JavaCore.create(project);
IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });
JavaSearchScopePackageLister packageLister = new JavaSearchScopePackageLister(searchScope, window);
// Create and open the dialog
PackageSelectionDialog dialog = new PackageSelectionDialog(window.getShell(), packageLister, filter, "Select new packages to export from the bundle.");
dialog.setSourceOnly(true);
dialog.setMultipleSelection(true);
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
added = new LinkedList<ExportedPackage>();
// Select the results
for (Object result : results) {
String newPackageName = (String) result;
ExportedPackage newPackage = new ExportedPackage(newPackageName, new Attrs());
added.add(newPackage);
}
}
return added;
}
use of aQute.bnd.build.model.clauses.ExportedPackage in project bnd by bndtools.
the class BndEditModel method isIncludedPackage.
public boolean isIncludedPackage(String packageName) {
final Collection<String> privatePackages = getPrivatePackages();
if (privatePackages != null) {
if (privatePackages.contains(packageName))
return true;
}
final Collection<ExportedPackage> exportedPackages = getExportedPackages();
if (exportedPackages != null) {
for (ExportedPackage pkg : exportedPackages) {
if (packageName.equals(pkg.getName())) {
return true;
}
}
}
return false;
}
use of aQute.bnd.build.model.clauses.ExportedPackage in project bnd by bndtools.
the class BndEditModelTest method testVariableInSystemPackages.
public static void testVariableInSystemPackages() throws Exception {
Workspace ws = new Workspace(new File("testresources/ws"));
BndEditModel model = new BndEditModel(ws);
File f = new File("testresources/ws/p7/syspkg.bndrun");
model.setBndResource(f);
model.setBndResourceName("syspkg.bndrun");
model.loadFrom(f);
List<ExportedPackage> ep = model.getSystemPackages();
assertEquals("com.sun.xml.internal.bind", model.getProperties().mergeProperties(Constants.RUNSYSTEMPACKAGES));
ExportedPackage e = new ExportedPackage("testing", null);
ep = new LinkedList<ExportedPackage>();
ep.add(e);
model.setSystemPackages(ep);
ep = model.getSystemPackages();
assertEquals(1, ep.size());
assertEquals("testing", ep.get(0).getName());
e = new ExportedPackage("${var}", null);
ep = new LinkedList<ExportedPackage>();
ep.add(e);
model.setSystemPackages(ep);
ep = model.getSystemPackages();
assertEquals(1, ep.size());
assertEquals("com.sun.xml.internal.bind", model.getProperties().mergeProperties(Constants.RUNSYSTEMPACKAGES));
}
Aggregations