Community
Participate
Working Groups
Build Identifier: Build id: M20100211-1343 Adding CDT Nature and Managed Build to an existing project requires using of not public API-s of CDT The following packages need to be imported: org.eclipse.cdt.managedbuilder.internal.core.Configuration org.eclipse.cdt.managedbuilder.internal.core.ManagedProject The following quotation explains modetails: http://cdt-devel-faq.wikidot.com/#toc25 If you have an existing project type and want to add CDT capabilities & features to it, you can try the code below in your plug-in: CProjectNature.addCNature(fProject, mon); ICProjectDescriptionManager mgr = CoreModel.getDefault().getProjectDescriptionManager(); ICProjectDescription des = mgr.getProjectDescription(fProject, true); if (des != null) return; // C project description already exists des = mgr.createProjectDescription(fProject, true); ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(fProject); IProjectType projType = ManagedBuildManager.getExtensionProjectType("my.project.type"); // or get projectType from UI IToolChain toolChain = ManagedBuildManager.getExtensionToolChain("my.toolchain"); // or get toolChain from UI ManagedProject mProj = new ManagedProject(fProject, projType); info.setManagedProject(mProj); IConfiguration[] configs = ManagedBuildManager.getExtensionConfigurations(toolChain, projType); for (IConfiguration icf : configs) { if (!(icf instanceof Configuration)) { continue; } Configuration cf = (Configuration) icf; String id = ManagedBuildManager.calculateChildId(cf.getId(), null); Configuration config = new Configuration(mProj, cf, id, false, true); ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, config.getConfigurationData()); config.setConfigurationDescription(cfgDes); config.exportArtifactInfo(); IBuilder bld = config.getEditableBuilder(); if (bld != null) { bld.setManagedBuildOn(true); } config.setName(toolChain.getName()); config.setArtifactName(fProject.getName()); } mgr.setProjectDescription(fProject, des); Of course, you have to replace "my.project.type" and "my.toolchain" with the appropriate CDT project type and toolchains, respectively. There's still one caveat, though. You will notice the code directly instantiates an instance of Configuration which is inside an internal package of CDT. Unfortunately, as of now there's no "valid" way to create it with the same parameters as we did. We will have to request an addition to the API to support this. Reproducible: Always
Actually, you can checkout what I'm doing here: https://github.com/dschaefer/adt-cdt
Hey Doug, how is that related to the issue described? Maybe you can point to more exact location where to look for the answer? Thanks! (In reply to comment #1) > Actually, you can checkout what I'm doing here: > > https://github.com/dschaefer/adt-cdt
I was able to do as suggested by using the STDWizardHandler which hides all the internals you are trying to use. You can see it in the NDKWizardHander in my project on github.