use of bndtools.editor.model.BndProject in project bndtools by bndtools.
the class AbstractNewBndProjectWizard method processGeneratedProject.
/**
* Modify the newly generated Java project; this method is executed from within a workspace operation so is free to
* make workspace resource modifications.
*
* @throws CoreException
*/
protected void processGeneratedProject(ProjectPaths projectPaths, BndEditModel bndModel, IJavaProject project, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 3);
Document document = new Document("");
bndModel.saveChangesTo(document);
progress.worked(1);
ByteArrayInputStream bndInput;
try {
bndInput = new ByteArrayInputStream(document.get().getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
return;
}
IFile bndBndFile = project.getProject().getFile(Project.BNDFILE);
if (bndBndFile.exists()) {
bndBndFile.setContents(bndInput, false, false, progress.newChild(1));
}
BndProject proj = generateBndProject(project.getProject(), progress.newChild(1));
progress.setWorkRemaining(proj.getResources().size());
for (Map.Entry<String, BndProjectResource> resource : proj.getResources().entrySet()) {
importResource(project.getProject(), resource.getKey(), resource.getValue(), progress.newChild(1));
}
if (!bndBndFile.exists()) {
bndBndFile.create(bndInput, false, progress.newChild(1));
}
/* Version control ignores */
VersionControlIgnoresManager versionControlIgnoresManager = Plugin.getDefault().getVersionControlIgnoresManager();
Set<String> enabledIgnorePlugins = new BndPreferences().getVersionControlIgnoresPluginsEnabled(versionControlIgnoresManager, project, null);
Map<String, String> sourceOutputLocations = JavaProjectUtils.getSourceOutputLocations(project);
versionControlIgnoresManager.createProjectIgnores(enabledIgnorePlugins, project.getProject().getLocation().toFile(), sourceOutputLocations, projectPaths.getTargetDir());
/* Headless build files */
HeadlessBuildManager headlessBuildManager = Plugin.getDefault().getHeadlessBuildManager();
Set<String> enabledPlugins = new BndPreferences().getHeadlessBuildPluginsEnabled(headlessBuildManager, null);
headlessBuildManager.setup(enabledPlugins, false, project.getProject().getLocation().toFile(), true, enabledIgnorePlugins, new LinkedList<String>());
/* refresh the project; files were created outside of Eclipse API */
project.getProject().refreshLocal(IResource.DEPTH_INFINITE, progress);
project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, progress);
}
Aggregations