if (profileName != null) {
System.setProperty("osgi.java.profile", profileName);
}
BundleResolver stateController = new BundleResolver(getLogger());
List<String> classpath;
try {
classpath = (List<String>)project.getCompileClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
for (String path : classpath) {
try {
File cp = new File(path);
if (log.isDebugEnabled()) {
log.debug("Adding bundle: " + cp);
}
if (cp.exists()) {
stateController.addBundle(cp);
}
} catch (BundleException e) {
log.error(e.getMessage(), e);
}
}
stateController.resolveState();
BundleDescription b = stateController.getBundleDescription(targetDir);
if (b != null) {
log.info("Resolving OSGi bundle: " + b.getSymbolicName());
try {
stateController.assertResolved(b);
log.info("OSGi bundle is resolved: " + b.getSymbolicName());
} catch (BundleException e) {
stateController.analyzeErrors(b);
if (failOnError) {
throw new MojoExecutionException("OSGi bundle resolution failed");
}
}
}