Search code examples
javaeclipseeclipse-plugineclipse-cdt

Programmatically disabling the CDT builder on a programmatically created C project


I'm creating a C project programmatically using CDT:

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();

    String projectName = projectNames[indices[i]];

    IProject newProjectHandle = root.getProject(projectName.replace("Examples_", ""));

    IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
    IProject project = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new NullProgressMonitor());

    ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
    ICProjectDescription des = mngr.createProjectDescription(project, false);
    ManagedProject mProj = new ManagedProject(des);


    Configuration cfg = new Configuration(mProj, null, projectName + ".id", projectName);
    cfg.setManagedBuildOn(false);
    IBuilder bld = cfg.getEditableBuilder();

    bld.setManagedBuildOn(false);
    bld.setAutoBuildEnable(false);


    CConfigurationData data = cfg.getConfigurationData();
    des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);


    mngr.setProjectDescription(project, des);

This works exactly as creating a makefile project from the C wizard.

What I want now is to programmatically untick the CDT builder from the project properties.

enter image description here

Is there any easy way to do this by adding a line or two to my project creation code?


Solution

  • Ok managed to change the code so that it creates the C projects without the builders:

                IWorkspace workspace = ResourcesPlugin.getWorkspace();
                IWorkspaceRoot root = workspace.getRoot();
    
                String projectName = projectNames[indices[i]];
    
                IProject newProjectHandle = root.getProject(projectName.replace("Examples_", ""));
    
                newProjectHandle.create(new NullProgressMonitor());
                IProjectDescription description = workspace
                        .newProjectDescription(newProjectHandle.getName());
    
                newProjectHandle = CCorePlugin.getDefault().createCProject(description,
                        newProjectHandle, new NullProgressMonitor(),
                        ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID);
                IndexerPreferences.set(newProjectHandle,
                        IndexerPreferences.KEY_INCLUDE_HEURISTICS, "true");