*/
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 {
if (container == null) {
container = new IvyClasspathContainer(project, containerPath,
new IClasspathEntry[0]);
} else if (!(container instanceof IvyClasspathContainer)) {
// this might be the persisted one : reuse the persisted entries
container = new IvyClasspathContainer(project, containerPath, container
.getClasspathEntries());
}
JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {project},
new IClasspathContainer[] {container}, null);