I am using Gradle 6.5.1. I have added a custom resolutionStrategy to a build.gradle
file - but now an exclusion like this is not being applied:
testImplementation("com.example:foo-bar_2.12:$dependencies_version"){
exclude group: 'org.scala-lang', module: 'scala-library'
exclude group: 'org.typelevel', module: 'cats-core_2.12' // <- !! NOT WORKING !!
}
So it seems that custom resolutionStrategies and exclusions are not composable, at least not by default, in Gradle 6.5.1. Is there some way I can make Gradle fall back to its "default" resolutionStrategy if mine is not relevant? If not, what should I do?
Issue
You have to have some special resolutionStrategy in place in order to overwrite the exclusion for cats-core_2.12.
Or
Dependency on cats-core_2.12 is being resolved as transitive dependency from other dependency and not com.example:foo-bar_2.12 as you expect. You should use gradle dependency command and post here the result of where cats-core is being resolved.
Example
I have following simple build.gradle build script with similar exclusion rule and resolutionStrategy as you can see below and cats-core will still be excluded from dependencies as expected
Dependencies:
Running following command
./gradlew dependencies
You can see that cats-core is not listed in dependencies as it's excluded.
Alternative
If exclusion in your case is not forking for specific dependency, maybe exclusion for all configurations might help like example below: