*/
public ISigilBundle getBundle(String id, IBldBundle bundle)
{
ISigilBundle sigilBundle = new SigilBundle();
IBundleModelElement info = new BundleModelElement();
sigilBundle.setBundleInfo(info);
// exports
// FIXME: UI doesn't understand export wildcard packages
for (IPackageExport export : bundle.getExports())
{
IPackageExport clone = (IPackageExport) export.clone();
clone.setParent(null);
info.addExport(clone);
}
// imports
for (IPackageImport import1 : bundle.getImports())
{
IPackageImport clone = (IPackageImport) import1.clone();
clone.setParent(null);
info.addImport(clone);
}
// requires
for (IRequiredBundle require : bundle.getRequires())
{
IRequiredBundle clone = (IRequiredBundle) require.clone();
clone.setParent(null);
info.addRequiredBundle(clone);
}
// fragment
IRequiredBundle fragment = bundle.getFragmentHost();
if (fragment != null)
{
info.setFragmentHost(fragment);
}
// contents
for (String pkg : bundle.getContents())
{
sigilBundle.addPackage(pkg);
}
// sources
for (String source : config.getList(null, BldConfig.L_SRC_CONTENTS))
{
sigilBundle.addClasspathEntry(String.format(classpathFormat, "src", source));
}
// libs
Map<String, Map<String, String>> libs = bundle.getLibs();
for (String path : libs.keySet())
{
Map<String, String> attr = libs.get(path);
String kind = attr.get(BldAttr.KIND_ATTRIBUTE);
if ("classpath".equals(kind))
{
sigilBundle.addClasspathEntry(String.format(classpathFormat, "lib", path));
}
else
{
BldCore.error("Can't convert -libs kind=" + kind);
}
}
// resources
// FIXME: UI doesn't support -resources: path1=path2
List<Resource> resources = bundle.getResources();
for (Resource resource : resources)
{
sigilBundle.addSourcePath(resource);
}
////////////////////
// simple headers
info.setSymbolicName(bundle.getSymbolicName());
info.setVersion(VersionTable.getVersion(bundle.getVersion()));
String activator = bundle.getActivator();
if (activator != null)
info.setActivator(activator);
Properties headers = config.getProps(id, BldConfig.P_HEADER);
String header;
header = headers.getProperty("CATEGORY");
if (header != null)
info.setCategory(header);
header = headers.getProperty(Constants.BUNDLE_CONTACTADDRESS);
if (header != null)
info.setContactAddress(header);
header = headers.getProperty(Constants.BUNDLE_COPYRIGHT);
if (header != null)
info.setCopyright(header);
header = headers.getProperty(Constants.BUNDLE_DESCRIPTION);
if (header != null)
info.setDescription(header);
header = headers.getProperty(Constants.BUNDLE_VENDOR);
if (header != null)
info.setVendor(header);
header = headers.getProperty(Constants.BUNDLE_NAME);
if (header != null)
info.setName(header);
header = headers.getProperty(Constants.BUNDLE_DOCURL);
if (header != null)
info.setDocURI(URI.create(header));
header = headers.getProperty(Constants.BUNDLE_LICENSE);
if (header != null)
info.setDocURI(URI.create(header));
return sigilBundle;
}