I want to automatically fail a build when a cyclic dependency is detected (to avoid build loops in Jenkins, among other things). The problem is the detection.
Maven 3 itself detects cyclic dependencies when the cyclic dependency is within the reactor (ie. executed from the same top-level module). Otherwise it is useless in that regard.
There is the extra maven enforcer rule banCircularDependencies. However, it seems to be limited to what "mvn dependency:tree" does, ie. it fails to recognize transitive test scope dependencies.
scope
The scope to filter by when resolving the dependency tree, or null to
include dependencies from all scopes. Note that this feature does not
currently work due to MNG-3236.
Is there any other solution to that problem?
One way is to set up a unit test using the JDepend API and assertions corresponding to what you want.