StackOverflowError in DefaultResolvedDependency.getAllModuleArtifacts when the project depends on itself

Gradle 2.8.
If a project depends on itself you will have StackOverflowError instead of a friendly error message:
Caused by: java.lang.StackOverflowError at org.gradle.api.internal.artifacts.DefaultResolvedDependency.getAllModuleArtifacts(DefaultResolvedDependency.java:87) at org.gradle.api.internal.artifacts.DefaultResolvedDependency.getAllModuleArtifacts(DefaultResolvedDependency.java:89) at org.gradle.api.internal.artifacts.DefaultResolvedDependency.getAllModuleArtifacts(DefaultResolvedDependency.java:89) ...

In my case DefaultResolvedDependency.getAllModuleArtifacts is called from ‘ca.cutterslade.gradle:gradle-dependency-analyze’ plugin and circular dependency came from the parent buildfile via subprojects { dependency { … }}.

Thanks for the report: I’ve confirmed this and raised GRADLE-3378 to track it.

Would you be interested in contributing a fix? I think the fix would be in DefaultResolvedDependency, and we’d need some unit test coverage in DefaultResolvedDependencySpec.