if (IvyClasspathContainerHelper.isIvyClasspathContainer(containerPath)) {
IvyDEMessage.info("Initializing container " + 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.logError("Unable to get container for " + containerPath.toString(), ex);
return;
}
try {
boolean refresh = false;
IvyClasspathContainerImpl ivycp = null;
IClasspathEntry entry = IvyClasspathContainerHelper.getEntry(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 IvyClasspathContainerImpl) {
IvyDEMessage.debug("Container already configured");
ivycp = (IvyClasspathContainerImpl) container;
} else {
if (container == null) {
IvyDEMessage.debug("No saved container");
// try what the IvyDE plugin saved
IvyClasspathContainerSerializer serializer = IvyPlugin.getDefault()
.getIvyClasspathContainerSerializer();
Map ivycps = serializer.read(project);
if (ivycps != null) {
IvyDEMessage.debug("Found serialized containers");
ivycp = (IvyClasspathContainerImpl) ivycps.get(containerPath);
}
if (ivycp == null) {
IvyDEMessage.debug("No serialized containers match the expected container path");
// still bad luck or just a new classpath container
ivycp = new IvyClasspathContainerImpl(project, containerPath,
new IClasspathEntry[0], attributes);
// empty, so force refresh at least
refresh = true;
}
} else {
IvyDEMessage.debug("Loading from a saved container");
// this might be the persisted one : reuse the persisted entries
ivycp = new IvyClasspathContainerImpl(project, containerPath,
container.getClasspathEntries(), attributes);
}
}
// FIXME : container path upgrade removed since it seems to make some trouble:
// containers get either uninitialized or initialized twice...