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 {
`java-library`
}
repositories {
jcenter()
}
dependencies {
// Creating conflct on animal-sniffer
implementation("com.google.guava:guava:27.0.1-jre")
implementation("org.codehaus.mojo:animal-sniffer-annotations:1.16")
// Creating conflict on hamcrest
testImplementation("org.hamcrest:hamcrest-core:1.2")
testImplementation("junit:junit:4.12")
}
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")
}
}
}
}
}