}
static Builder setupBuilderForBndFile(File file) throws IOException, CoreException {
IFile[] wsfiles = FileUtils.getWorkspaceFiles(file);
if (wsfiles == null || wsfiles.length == 0)
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Unable to determine project owner for Bnd file: " + file.getAbsolutePath(), null));
IProject project = wsfiles[0].getProject();
// Calculate the manifest
try {
Project bndProject = Central.getInstance().getModel(JavaCore.create(project));
if (bndProject == null)
return null;
Builder builder;
if (file.getName().equals(Project.BNDFILE)) {
builder = bndProject.getSubBuilders().iterator().next();
} else {
builder = bndProject.getSubBuilder(file);
}
if (builder == null) {
builder = new Builder();
builder.setProperties(file);
}
builder.build();
return builder;
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Bnd analysis failed", e));
}
}