*/
public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
if (IvyClasspathUtil.isIvyClasspathContainer(containerPath)) {
// try to get an existing one
IClasspathContainer container = null;
try {
container = JavaCore.getClasspathContainer(containerPath, project);
} catch (JavaModelException ex) {
// unless there are issues with the JDT, this should never happen
IvyPlugin.log(IStatus.ERROR,
"Unable to get container for " + containerPath.toString(), ex);
return;
}
try {
IvyClasspathContainer ivycp;
IClasspathEntry entry = IvyClasspathUtil.getIvyClasspathEntry(containerPath,
project);
IClasspathAttribute[] attributes;
boolean exported;
if (entry != null) {
attributes = entry.getExtraAttributes();
exported = entry.isExported();
} else {
exported = false;
attributes = new IClasspathAttribute[0];
}
if (container instanceof IvyClasspathContainer) {
ivycp = (IvyClasspathContainer) container;
} else {
if (container == null) {
ivycp = new IvyClasspathContainer(project, containerPath,
new IClasspathEntry[0], attributes);
} else {
// this might be the persisted one : reuse the persisted entries
ivycp = new IvyClasspathContainer(project, containerPath,
container.getClasspathEntries(), attributes);
}
}
// recompute the path as it may have been "upgraded"
IPath updatedPath = IvyClasspathContainerConfAdapter.getPath(ivycp.getConf());