Custom rule for conflict resolution


I would like to implement a rule which makes the build fail when a conflict resolution exist between 2 incompatible semver versions of a module. This means it should fail when the major version differ between the 2 candidates (1.0.0 vs 2.0.0).
I did not find any plugin allowing to do that, I only found this old forum post : Semantic Versioning Dependency Conflict Resolution Strategy
I try to find a way to plug my custom rule but with no luck until now. Looking at the Gradle source code I guess I should extend a ModuleConflictResolver or a ModuleConflictHandler but I can’t find a place to inject my custom class. It looks like it is not designed to be customizable.

As a workaround, I added a DependencyResolutionListener and relied on the selection reason of the ResolvedComponentResult to extract the 2 conflicting versions. This means parsing the message “between versions a.b.c and x.y.z”, which is quite ugly and fragile…

Is there a better way to do what I want?