Unable to set project dependency programatically [message #1409817] |
Tue, 19 August 2014 00:03  |
Eclipse User |
|
|
|
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 00:20  |
Eclipse User |
|
|
|
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
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.30377 seconds