use of org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry in project arduino-eclipse-plugin by Sloeber.
the class BoardDescriptor method createProject.
/*
* Method to create a project based on the board
*/
public IProject createProject(String projectName, URI projectURI, ArrayList<ConfigurationDescriptor> cfgNamesAndTCIds, CodeDescriptor codeDescription, CompileOptions compileOptions, IProgressMonitor monitor) throws Exception {
IProject projectHandle;
projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(Common.MakeNameCompileSafe(projectName));
// try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription desc = workspace.newProjectDescription(projectHandle.getName());
desc.setLocationURI(projectURI);
projectHandle.create(desc, monitor);
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
projectHandle.open(IResource.BACKGROUND_REFRESH, monitor);
// Creates the .cproject file with the configurations
ICProjectDescription prjCDesc = ShouldHaveBeenInCDT.setCProjectDescription(projectHandle, cfgNamesAndTCIds, true, monitor);
// Add the C C++ AVR and other needed Natures to the project
Helpers.addTheNatures(desc);
// Add the Arduino folder
Helpers.createNewFolder(projectHandle, Const.ARDUINO_CODE_FOLDER_NAME, null);
for (ConfigurationDescriptor curConfig : cfgNamesAndTCIds) {
ICConfigurationDescription configurationDescription = prjCDesc.getConfigurationByName(curConfig.configName);
compileOptions.save(configurationDescription);
save(configurationDescription);
}
// Set the path variables
// ArduinoHelpers.setProjectPathVariables(prjCDesc.getActiveConfiguration());
// Intermediately save or the adding code will fail
// Release is the active config (as that is the "IDE" Arduino
// type....)
ICConfigurationDescription defaultConfigDescription = prjCDesc.getConfigurationByName(cfgNamesAndTCIds.get(0).configName);
ICResourceDescription cfgd = defaultConfigDescription.getResourceDescription(new Path(new String()), true);
ICExclusionPatternPathEntry[] entries = cfgd.getConfiguration().getSourceEntries();
if (entries.length == 1) {
Path[] exclusionPath = new Path[6];
exclusionPath[0] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/?xamples/**");
exclusionPath[1] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/?xtras/**");
exclusionPath[2] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/test*/**");
exclusionPath[3] = new Path(LIBRARY_PATH_SUFFIX + "/?*/**/third-party/**");
exclusionPath[4] = new Path(LIBRARY_PATH_SUFFIX + "/**/._*");
exclusionPath[5] = new Path(LIBRARY_PATH_SUFFIX + "/?*/utility/*/*");
ICExclusionPatternPathEntry newSourceEntry = new CSourceEntry(entries[0].getFullPath(), exclusionPath, ICSettingEntry.VALUE_WORKSPACE_PATH);
ICSourceEntry[] out = null;
out = new ICSourceEntry[1];
out[0] = (ICSourceEntry) newSourceEntry;
try {
cfgd.getConfiguration().setSourceEntries(out);
} catch (CoreException e) {
// ignore
}
} else {
// this should not happen
}
Set<String> librariesToInstall = codeDescription.createFiles(projectHandle, monitor);
Libraries.addLibrariesToProject(projectHandle, defaultConfigDescription, librariesToInstall);
prjCDesc.setActiveConfiguration(defaultConfigDescription);
prjCDesc.setCdtProjectCreated();
CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(projectHandle, prjCDesc, true, null);
projectHandle.setDescription(desc, new NullProgressMonitor());
projectHandle.refreshLocal(IResource.DEPTH_INFINITE, null);
monitor.done();
return projectHandle;
}
Aggregations