failOnVersionConflict only for certain dependencies

Is it possible to enforce failOnVersionConflict() not for the entire configuration, but for only certain group dependency(by name or by group).

Running into this issue as well. Any ideas?

There is no built-in support for that, but with an afterResolve hook on a configuration, it is possible to achieve it in a custom way:

plugins {

repositories {

dependencies {
    // Creating conflct on animal-sniffer

    // Creating conflict on hamcrest

configurations {
    testCompileClasspath.get().incoming.afterResolve {
        resolutionResult.allComponents {
            if (selectionReason.isConflictResolution && moduleVersion != null) {
                if (moduleVersion!!.name.contains("hamcrest")) {
                    throw AssertionError("Cannot have a conflict on hamcrest")

I’m trying to do this with a Spring Boot app(2.2.4.RELEASE)-

Is there any way to do a similar thing that takes into account Spring Boot’s BOM?
I want to make sure the build doesn’t override anything from the spring bom.

That is a different use case.

Have a look at the documentation for using native support of BOMs in Gradle and enforced platforms as in the example in that linked section.