[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Creating a new build configuration programmatically
|
Hi,
I am trying to add new build configurations after converting a "plain"
Eclipse project to a CDT project. This is the code I have so far:
8<================
@SuppressWarnings("restriction")
public void convertToCProject(final IProject originalProject)
throws CoreException
{
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IWorkspaceRoot workspaceRoot = workspace.getRoot();
final IProject originalProjectHandle =
workspaceRoot.getProject(originalProject.getName());
final IProjectDescription newProjectDescription =
workspace.newProjectDescription(originalProjectHandle.getName());
CCorePlugin.getDefault().createCDTProject(newProjectDescription,
originalProjectHandle, new NullProgressMonitor());
final ICProjectDescriptionManager descriptionManager =
CoreModel.getDefault().getProjectDescriptionManager();
final ICProjectDescription projectDescription =
descriptionManager.createProjectDescription(originalProject, false);
final ManagedProject managedProject = new
ManagedProject(projectDescription);
Configuration newConfig = new Configuration(managedProject, null,
"MyConfigID", "MyConfigName");
Configuration otherConfig = new Configuration(managedProject,
newConfig, "OtherConfigID", true, false);
addConfiguration(originalProject, projectDescription, newConfig);
addConfiguration(originalProject, projectDescription, otherConfig);
CoreModel.getDefault().setProjectDescription(originalProject,
projectDescription);
}
@SuppressWarnings("restriction")
private void addConfiguration(final IProject originalProject,
final ICProjectDescription projectDescription,
final Configuration managedProjectConfiguration)
throws CoreException
{
final IBuilder managedProjectBuilder =
managedProjectConfiguration.getEditableBuilder();
managedProjectBuilder.setManagedBuildOn(false);
managedProjectBuilder.setAutoBuildEnable(false);
managedProjectBuilder.setIncrementalBuildEnable(false);
managedProjectBuilder.setCleanBuildEnable(false);
final CConfigurationData managedProjectConfigData =
managedProjectConfiguration.getConfigurationData();
projectDescription.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID,
managedProjectConfigData);
}
8<================
However, the only Build Configuration I am seeing after the conversion
(convertToCProject() method) is the "MyConfigName" configuration.
Could someone please give me a hint what I am doing wrong here? As I
get some warnings regarding discouraged access to internal methods
(@SuppressWarnings("restriction")) I am feeling quite uncomfortable
with this code as well. Shall I use the CDT extension points
(http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.cdt.doc.isv%2Freference%2Fextension-points%2Findex.html)
to achieve my goal? If so, which one?
Thanks for your help,
Rainer