Forced dependency resolution bypasses excludes statements


#1

I don’t know if this is a bug or a feature, however for me the results were somewhat unexpected in Gradle 1.10

I have the following dependency code:

configurations.all {
   resolutionStrategy {
       eachDependency { DependencyResolveDetails details ->
           if (details.requested.group == 'com.oracle.jdbc') {
               details.useTarget 'com.oracle.jdbc:ojdbc6:11.2.0.2.0'
           }
       }
   }
}

Later in the build I also have:

configurations.all {
    exclude group:'com.oracle.jdbc' module:'ojdbc6'
}

The problem is that when a dependency includes ‘com.oracle.jdbc:ojdbc14’, it gets updated to ojdbc6 and remains in the configuration, ignoring the exclude statement. It looks like the exclude is applied before the mapping resolution step.

Should the excludes be also applied after the resolutionStrategy is applied? Is there a way to fix this, other than adding a manual exclude for ojdbc14?