use of aQute.bnd.build.model.EE in project bnd by bndtools.
the class BndrunResolveContext method init.
/**
* Initializes the resolver. Here we will load all the information from the
* model.
*/
@Override
public synchronized void init() {
if (initialized)
return;
initialized = true;
try {
if (getLevel() <= 0) {
Integer level = Converter.cnv(Integer.class, properties.getProperty("-resolvedebug", "0"));
if (level != null)
setLevel(level);
}
loadPreferences();
Processor augments = loadRepositories();
constructBlacklist(augments);
Map<String, Set<String>> effectiveSet = loadEffectiveSet();
if (effectiveSet != null)
addEffectiveSet(effectiveSet);
//
// Create a resource from the -runrequire that contains
// all the requirement
//
setInputResource(constructInputRequirements());
//
// We gradually build up the system resource that contains
// the system packages, the EE, etc.
//
ResourceBuilder system = new ResourceBuilder();
//
// Let's identify the system resource to make it look less
// ugly
//
//
// If we have a distro, we do not load the environment
// settings
//
String distro = properties.mergeProperties(Constants.DISTRO);
if (distro != null && !distro.trim().isEmpty()) {
loadPath(system, distro, Constants.DISTRO);
loadProvidedCapabilities(system);
} else {
//
// Load the EE's and packages that belong to it.
//
EE tmp = EE.parse(properties.getProperty(Constants.RUNEE));
EE ee = (tmp != null) ? tmp : EE.JavaSE_1_6;
system.addAllExecutionEnvironments(ee);
//
// We make the system packages as coming from the system
// resource
//
Parameters systemPackages = new Parameters(properties.mergeProperties(Constants.RUNSYSTEMPACKAGES), project);
system.addExportPackages(systemPackages);
//
// We make the system capabilities as coming from the system
// resource
//
Parameters systemCapabilities = new Parameters(properties.mergeProperties(Constants.RUNSYSTEMCAPABILITIES), project);
system.addProvideCapabilities(systemCapabilities);
loadProvidedCapabilities(system);
//
// Load the frameworks capabilities
//
loadFramework(system);
//
// Analyze the path and add all exported packages and provided
// capabilities
// to the system resource
//
String runpath = properties.mergeProperties(Constants.RUNPATH);
if (runpath != null && !runpath.trim().isEmpty())
loadPath(system, runpath, Constants.RUNPATH);
}
//
// We've not gathered all the capabilities of the system
// so we can create the resource and set it as the system resource
//
//
// TODO Add osgi.wiring.bundle + osgi.wiring.host
// filed a bug about using the impl version for the system
// capabilities
//
List<Capability> frameworkPackages = system.findCapabilities(PackageNamespace.PACKAGE_NAMESPACE, "(" + PackageNamespace.PACKAGE_NAMESPACE + "=org.osgi.framework)");
if (!frameworkPackages.isEmpty()) {
Capability c = frameworkPackages.get(0);
Version version = (Version) c.getAttributes().get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE);
CapReqBuilder crb = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE);
crb.addAttribute(IdentityNamespace.IDENTITY_NAMESPACE, "system.bundle");
crb.addAttribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
system.addCapability(crb);
}
setSystemResource(system.build());
} catch (Exception e) {
log.log(LogService.LOG_ERROR, e.getMessage(), e);
throw new RuntimeException(e);
}
super.init();
}
use of aQute.bnd.build.model.EE in project bndtools by bndtools.
the class ResolveJob method validateBeforeRun.
public IStatus validateBeforeRun() {
try {
//
// The BndEdit model does not do property expansion. So
// get the processor to get the expansions.
//
Processor p = model.getProperties();
String runfw = p.getProperty(Constants.RUNFW);
if (runfw == null)
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, Messages.ResolutionJob_errorFrameworkOrExecutionEnvironmentUnspecified, null);
EE ee = EE.parse(p.getProperty(Constants.RUNEE));
if (ee == null)
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, Messages.ResolutionJob_errorFrameworkOrExecutionEnvironmentUnspecified, null);
return Status.OK_STATUS;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of aQute.bnd.build.model.EE in project bnd by bndtools.
the class ResourceBuilder method addEE.
public void addEE(EE ee) throws Exception {
addExportPackages(ee.getPackages());
EE[] compatibles = ee.getCompatible();
addExecutionEnvironment(ee);
for (EE compatible : compatibles) {
addExecutionEnvironment(compatible);
}
}
use of aQute.bnd.build.model.EE in project bnd by bndtools.
the class ResourceBuilder method addAllExecutionEnvironments.
public void addAllExecutionEnvironments(EE ee) throws Exception {
addExportPackages(ee.getPackages());
addExecutionEnvironment(ee);
for (EE compatibleEE : ee.getCompatible()) {
addExecutionEnvironment(compatibleEE);
}
}
Aggregations