IResolution resolution = resolver.resolve(requirements, false);
Log.verbose("resolution: " + resolution.getBundles());
ModuleRevisionId masterMrid = md.getModuleRevisionId();
DefaultDependencyDescriptor dd;
ModuleRevisionId mrid;
for (ISigilBundle bundle : resolution.getBundles())
{
IBundleModelElement info = bundle.getBundleInfo();
String name = info.getSymbolicName();
if ("system bundle".equals(name))
{
// e.g. SystemProvider with framework=null
Log.verbose("Discarding system bundle");
continue;
}
ModuleDescriptor bmd = (ModuleDescriptor) bundle.getMeta().get(
ModuleDescriptor.class);
if (bmd != null)
{
ModuleRevisionId bmrid = bmd.getModuleRevisionId();
String org = bmrid.getOrganisation();
if (org == null)
org = masterMrid.getOrganisation();
String module = bmrid.getName();
String rev = "latest." + bmd.getStatus();
mrid = ModuleRevisionId.newInstance(org, module, rev);
dd = new SigilDependencyDescriptor(md, mrid, force, changing,
transitive);
Artifact artifact = (Artifact) bundle.getMeta().get(Artifact.class);
if (artifact != null)
{
dd.addDependencyArtifact(mrid.getName(),
new DefaultDependencyArtifactDescriptor(dd,
artifact.getName(), "jar", "jar", null, null));
}
}
else
{
// XXX see FELIX-1395
// The following code has been commented out as it causes
// problems with require bundle dependencies
// VersionRange version = versions.get( name );
// String rev = version != null ? version.toString() : info.getVersion().toString();
String rev = info.getVersion().toString();
mrid = ModuleRevisionId.newInstance(SigilResolver.ORG_SIGIL, name,
rev);
dd = new SigilDependencyDescriptor(md, mrid, force, changing,
transitive);
}
int nDeps = 0;
boolean foundDefault = false;
// TODO: make dependency configurations configurable SIGIL-176
for (String conf : md.getConfigurationsNames())
{
if (conf.equals("default"))
{
foundDefault = true;
}
else if (md.getArtifacts(conf).length == 0)
{
dd.addDependencyConfiguration(conf, conf + "(default)");
nDeps++;
}
}
if (nDeps > 0)
{
if (foundDefault)
dd.addDependencyConfiguration("default", "default");
}
else
{
dd.addDependencyConfiguration("*", "*"); // all configurations
}
md.addDependency(dd);
}
boolean resolved = true;
for (IModelElement child : requirements.children())
{
ISigilBundle provider = resolution.getProvider(child);
if (provider == null)
{
resolved = false;
// this is parse phase, so only log verbose message.
// error is produced during resolution phase.
Log.verbose("WARN: can't resolve: " + child);
String name;
String version;
if (child instanceof IRequiredBundle)
{
IRequiredBundle rb = (IRequiredBundle) child;
name = rb.getSymbolicName();
version = rb.getVersions().toString();
}
else
{
IPackageImport pi = (IPackageImport) child;
name = "import!" + pi.getPackageName();
version = pi.getVersions().toString();
}
mrid = ModuleRevisionId.newInstance("!" + SigilResolver.ORG_SIGIL,
name, version);
dd = new SigilDependencyDescriptor(md, mrid, force, changing,
transitive);
dd.addDependencyConfiguration("*", "*"); // all
// configurations
md.addDependency(dd);
}
}