Exclude class depilation in compilation, but include in testCompile for gradle

I had a problem when I have an old version of the Foo library as a transitive dependency in one of my included libraries. I want to use the newer version of the Foo library in my testCompile, but this causes a conflict when running tests in intelliJ, since intelliJ uses the older Foo lib by default.

I tried to exclude Foo and then explicitly included it in testCompile, but it seems that the exception overrides include in testCompile.

I am currently using the following for force resolution, but I would prefer that I do not force compilation to a specific version.

configurations.all {
  resolutionStrategy {
    force 'org.foo:bar:1.0'
  }
}
+4
source share
1

.module.scopes.TEST :

idea {
  module {
     scopes.TEST.minus += ['org.foo:bar:0.9-oldversion']
  }
}

gradle cleanIdea idea. testClasses, .

0

Source: https://habr.com/ru/post/1616246/


All Articles