I have tried to find problems out for few days in the following codes but I couldn't.
My problems was stuck at "IManagedProject mProj = new ManagedProject(newProject,projType);"
Anyone knows what the problem is?
try {
ManagedCProjectNature.addNature(newProject, "org.eclipse.cdt.make.core.makeNature", null);
ManagedCProjectNature.addManagedBuilder(newProject, null);
} catch (CoreException e2) {
e2.printStackTrace();
}
ICProjectDescriptionManager mgr = CoreModel.getDefault().getProjectDescriptionManager();
ICProjectDescription des = mgr.getProjectDescription(newProject, true);
try {
des = mgr.createProjectDescription(newProject, true);
} catch (CoreException e2) {
e2.printStackTrace();
}
IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(newProject);
IProjectType projType = ManagedBuildManager.getExtensionProjectType("org.eclipse.cdt.build.core.buildType");
IToolChain toolChain = ManagedBuildManager.getExtensionToolChain("org.eclipse.cdt.build.core.prefbase.toolchain");
IManagedProject mProj = new ManagedProject(newProject,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((ManagedProject) mProj, cf, id, false, true);
ICConfigurationDescription cfgDes = null;
try {
cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID,config.getConfigurationData());
} catch (WriteAccessException e1) {
e1.printStackTrace();
} catch (CoreException e1) {
e1.printStackTrace();
}
config.setConfigurationDescription(cfgDes);
config.exportArtifactInfo();
IBuilder bld = config.getEditableBuilder();
if (bld != null) { try {
bld.setManagedBuildOn(true);
} catch (CoreException e) {
e.printStackTrace();
} }
config.setName(toolChain.getName());
config.setArtifactName(newProject.getName());
}
try {
mgr.setProjectDescription(newProject, des);
} catch (CoreException e1) {
e1.printStackTrace();
}