Skip to content

Commit

Permalink
Don't throw exception when circular dependencies are discovered. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
craigburke committed Sep 12, 2016
1 parent df25a6c commit db8bf66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Expand Up @@ -163,13 +163,18 @@ abstract class AbstractRegistry implements Registry {
.findAll { SimpleDependency child -> !exclusions.contains(child.name) }
.collectParallel { SimpleDependency child ->
if (dependency.ancestorsAndSelf*.name.contains(child.name)) {
String message = "Circular dependency created by dependency ${child.name}@${child.versionExpression}"
throw new CircularDependencyException(message)
null
}
else {
Dependency childDependency = new Dependency(
name: child.name,
versionExpression: child.versionExpression,
exclude: exclusions
)
loadDependency(childDependency, dependency)
}

Dependency childDependency = new Dependency(name: child.name, versionExpression: child.versionExpression)
loadDependency(childDependency, dependency)
}
.findAllParallel { it != null }
} as List<Dependency>
}

Expand Down
Expand Up @@ -4,7 +4,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
import static com.github.tomakehurst.wiremock.client.WireMock.get
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo

import com.craigburke.gradle.client.registry.core.CircularDependencyException
import com.craigburke.gradle.client.registry.core.Registry
import com.craigburke.gradle.client.registry.core.AbstractRegistry

Expand Down Expand Up @@ -188,15 +187,22 @@ abstract class AbstractRegistrySpec extends Specification {
dependency.children.every { it.parent == dependency }
}

def "circular dependencies are detected"() {
def "circular dependencies are ignored"() {
setup:
Dependency declaredDependency = new Dependency(name: 'circular1', versionExpression: '1.0.0')

when:
registry.loadDependency(declaredDependency, null)
Dependency circular1 = registry.loadDependency(declaredDependency, null)
Dependency circular2 = circular1.children.first()

then:
thrown(CircularDependencyException)
circular1.children.size() == 1

and:
circular2.name == 'circular2'

and:
circular2.children.size() == 0
}

}

0 comments on commit db8bf66

Please sign in to comment.