Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Unable to set project dependency programatically(Unable to set the project dependency under CDT's Paths and Symbols -> References)
Unable to set project dependency programatically [message #1409817] Tue, 19 August 2014 04:03 Go to next message
Anitha Mising name is currently offline Anitha Mising nameFriend
Messages: 28
Registered: February 2010
Junior Member
I am trying to add project references in CDT's Paths and Symbols and in Eclipse Project References. But it is getting added to Project References but not in CDT's Paths and Symbols. I am doing the following:

private void setProjectDependencies(IWorkspaceRoot root, IProject project,
IProjectDescription description) {
try {
Map <String, String> refMap = new HashMap<String, String>();
IProject[] depProjects = new IProject[projDependencies.length]; // projDependencies is a String array of dependent project names
for (int i=0; i< projDependencies.length; i++) {
depProjects[i] = root.getProject(projDependencies[i]);
refMap.put(projDependencies[i], ""); // Active Configuration
}
description.setReferencedProjects(depProjects);

// Set in CDT's Paths and Symbols too
CoreModel coreModel = CoreModel.getDefault();
ICProjectDescription desc = coreModel.getProjectDescription(project);
ICConfigurationDescription[] cDescriptions = desc.getConfigurations();
for (ICConfigurationDescription cfgDesc : cDescriptions) {
cfgDesc.setReferenceInfo(refMap);
}

project.setDescription(description, null);

} catch (CoreException e) {
// TODO: Throw error
}
}


Let me know what i am doing wrong here. Thanks.
Re: Unable to set project dependency programatically [message #1409823 is a reply to message #1409817] Tue, 19 August 2014 04:20 Go to previous message
Anitha Mising name is currently offline Anitha Mising nameFriend
Messages: 28
Registered: February 2010
Junior Member
Please ignore the above issue. The below code resolved the issue and it now adds the references.

private void setProjectDependencies(IWorkspaceRoot root, IProject project,
IProjectDescription description) {
if (projDependencies.length == 0) {
return;
}
try {
Map <String, String> refMap = new HashMap<String, String>();
IProject[] depProjects = new IProject[projDependencies.length];
for (int i=0; i< projDependencies.length; i++) {
depProjects[i] = root.getProject(projDependencies[i]);
refMap.put(projDependencies[i], ""); // Active Configuration
}
description.setReferencedProjects(depProjects);
project.setDescription(description, null);

// Set in CDT's Paths and Symbols too
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
ICProjectDescription prjDescription = mngr.getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
for (ICConfigurationDescription cfgDesc : cfgDescriptions) {
cfgDesc.setReferenceInfo(refMap);
}
mngr.setProjectDescription(project, prjDescription);

} catch (CoreException e) {
// TODO: Throw error
}
}
Previous Topic:Named Threads in IDE
Next Topic:Is There A Way to Refresh the Window > Preferences Programmatically?
Goto Forum:
  


Current Time: Sat Oct 05 16:53:30 GMT 2024

Powered by FUDForum. Page generated in 0.03664 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top