Skip to content

Commit

Permalink
Add cycle avoidance to classpath computation.
Browse files Browse the repository at this point in the history
Fixes #1002179.
  • Loading branch information
François Garillot committed Nov 26, 2014
1 parent 32eabf0 commit a49a0ec
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -158,18 +158,19 @@ trait ClasspathManagement extends HasLogger { self: ScalaProject =>

val computedClasspaths = mutable.HashSet[IJavaProject]()

def computeClasspath(project: IJavaProject): Unit = {
if (!computedClasspaths.contains(project)) {
def computeClasspath(project: IJavaProject, followedPath: List[IJavaProject]): Unit = {
// have we seen he project, or does is it part of a cyclic dependency
if (!computedClasspaths.contains(project) && !followedPath.contains(project)) {
val cpes = project.getResolvedClasspath(true)

for (
cpe <- cpes if project == javaProject || cpe.isExported ||
cpe.getEntryKind == IClasspathEntry.CPE_SOURCE
// we take only exported dependencies on classPath, except for the initial project for which we take all
cpe <- cpes if project == javaProject || cpe.isExported || cpe.getEntryKind == IClasspathEntry.CPE_SOURCE
) cpe.getEntryKind match {
case IClasspathEntry.CPE_PROJECT =>
val depProject = EclipseUtils.workspaceRoot.getProject(cpe.getPath.lastSegment)
if (JavaProject.hasJavaNature(depProject)) {
computeClasspath(JavaCore.create(depProject))
computeClasspath(JavaCore.create(depProject), project :: followedPath)
}
case IClasspathEntry.CPE_LIBRARY =>
if (cpe.getPath != null) {
Expand Down Expand Up @@ -197,7 +198,7 @@ trait ClasspathManagement extends HasLogger { self: ScalaProject =>
computedClasspaths += project
}
}
computeClasspath(javaProject)
computeClasspath(javaProject, List())
path.toList
}

Expand Down

0 comments on commit a49a0ec

Please sign in to comment.