}
context.set(contextId, dd);
ModuleRevisionId dependencyMrid = dd.getDependencyRevisionId();
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
// Iterate over workspace to find Java project which has an Ivy
// container for this dependency
for (int i = 0; i < projects.length; i++) {
IProject p = projects[i];
if (!p.exists()) {
continue;
}
List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper
.getContainers(p);
Iterator/* <IvyClasspathContainer> */itContainer = containers.iterator();
while (itContainer.hasNext()) {
IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainer.next();
ModuleDescriptor md = ivycp.getState().getCachedModuleDescriptor();
if (md == null) {
continue;
}
ModuleRevisionId candidateMrid = md.getModuleRevisionId();
if (!candidateMrid.getModuleId().equals(dependencyMrid.getModuleId())) {
// it doesn't match org#module
continue;
}
IvyDEMessage.verbose("Workspace resolver found potential matching project "
+ p.getName() + " with module " + candidateMrid + " for module "
+ dependencyMrid);
if (!ignoreBranchOnWorkspaceProjects) {
ModuleId mid = dependencyMrid.getModuleId();
String defaultBranch = getSettings().getDefaultBranch(mid);
String dependencyBranch = dependencyMrid.getBranch();
String candidateBranch = candidateMrid.getBranch();
if (dependencyBranch == null) {
dependencyBranch = defaultBranch;
}
if (candidateBranch == null) {
candidateBranch = defaultBranch;
}
if (dependencyBranch != candidateBranch) {
// Both cannot be null
if (dependencyBranch == null || candidateBranch == null) {
IvyDEMessage.verbose("\t\trejected since branches doesn't match (one is set, the other isn't)");
continue;
}
if (!dependencyBranch.equals(candidateBranch)) {
IvyDEMessage.verbose("\t\trejected since branches doesn't match");
continue;
}
}
}
// Found one; check if it is for the module we need
if (ignoreVersionOnWorkspaceProjects
|| md.getModuleRevisionId().getRevision().equals(Ivy.getWorkingRevision())
|| versionMatcher.accept(dd.getDependencyRevisionId(), md)) {
if (ignoreVersionOnWorkspaceProjects) {
IvyDEMessage.verbose("\t\tmatched (version are ignored)");
} else {
IvyDEMessage.verbose("\t\tversion matched");