progress.setWorkRemaining(3);
IProject cnfProject = ResourcesPlugin.getWorkspace().getRoot().getProject(Workspace.CNFDIR);
URI location = operation.getLocation() != null ? operation.getLocation().toFile().toURI() : null;
JavaCapabilityConfigurationPage.createProject(cnfProject, location, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
IJavaProject cnfJavaProject = JavaCore.create(cnfProject);
configureJavaProject(cnfJavaProject, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
String bsn = templateConfig.getContributor().getName();
Bundle bundle = BundleUtils.findBundle(Plugin.getDefault().getBundleContext(), bsn, null);
String paths = templateConfig.getAttribute("paths");
if (paths == null)
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Template is missing 'paths' property.", null));
StringTokenizer tokenizer = new StringTokenizer(paths, ",");
progress.setWorkRemaining(tokenizer.countTokens());
while (tokenizer.hasMoreTokens()) {
String path = tokenizer.nextToken().trim();
if (!path.endsWith("/"))
path = path + "/";
copyBundleEntries(bundle, path, new Path(path), cnfProject, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
}
try {
Central.getWorkspace().refresh();
} catch (Exception e) {
logger.logError("Unable to refresh Bnd workspace", e);
}
/* Version control ignores */
VersionControlIgnoresPluginTracker versionControlIgnoresPluginTracker = Plugin.getDefault().getVersionControlIgnoresPluginTracker();
Set<String> enabledIgnorePlugins = new BndPreferences().getVersionControlIgnoresPluginsEnabled(versionControlIgnoresPluginTracker, cnfJavaProject, null);
versionControlIgnoresPluginTracker.createProjectIgnores(enabledIgnorePlugins, cnfJavaProject, ProjectPaths.get(ProjectLayout.BND));
String templateIgnores = null;
try {
templateIgnores = templateConfig.getAttribute("ignores");
} catch (Exception e) {
logger.logError("Could not retrieve the 'ignores' property from the cnf template " + bsn, e);
}
if (templateIgnores != null && !templateIgnores.isEmpty()) {
versionControlIgnoresPluginTracker.addIgnores(enabledIgnorePlugins, cnfJavaProject.getProject().getLocation().toFile(), templateIgnores);
}
/* Headless build files */
HeadlessBuildPluginTracker headlessBuildPluginTracker = Plugin.getDefault().getHeadlessBuildPluginTracker();
Set<String> enabledPlugins = new BndPreferences().getHeadlessBuildPluginsEnabled(headlessBuildPluginTracker, null);
headlessBuildPluginTracker.setup(enabledPlugins, true, cnfJavaProject.getProject().getLocation().toFile(), true, enabledIgnorePlugins);
/* refresh the project; files were created outside of Eclipse API */
cnfProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
}