steps
Use this reproducer and execute sbt failingTask.
problem
A java.lang.StackOverflowError is thrown. This could be avoided by handling the recursion in the Throwable cause, similarly to how the JDK handles this when printing stacktraces.
// Guard against malicious overrides of Throwable.equals by
// using a Set with identity equality semantics.
Set<Throwable> dejaVu = Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
...
if (dejaVu.contains(this)) {
s.println(prefix + caption + "[CIRCULAR REFERENCE: " + this + "]"); // <---- This gets the code out of the recursion
}
expectation
The build is resilient to such Throwables.
notes