throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Bnd launch target was not specified, or does not exist.", null));
return getBndProject(targetResource);
}
public static Project getBndProject(IResource targetResource) throws CoreException {
Project result;
IProject project = targetResource.getProject();
File projectDir = project.getLocation().toFile();
if (targetResource.getType() == IResource.FILE && targetResource.getName().endsWith(LaunchConstants.EXT_BNDRUN)) {
if (!targetResource.getName().endsWith(LaunchConstants.EXT_BNDRUN))
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Bnd launch target file \"{0}\" is not a .bndrun file.", targetResource.getFullPath().toString()), null));
// Get the synthetic "run" project (based on a .bndrun file)
File runFile = targetResource.getLocation().toFile();
File bndbnd = new File(runFile.getParentFile(), Project.BNDFILE);
try {
Project parent = new Project(Central.getWorkspace(), projectDir, bndbnd);
result = new Project(Central.getWorkspace(), projectDir, runFile);
result.setParent(parent);
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to create synthetic project for run file {0} in project {1}.", targetResource.getProjectRelativePath().toString(),
project.getName()), e));
}