Shark
Shark

Reputation: 2382

Exclude a class depedency in compile, but include in testCompile for gradle

I'm having an issue where I have an old version of library Foo as a transitive dependency in one of my included libs. I want to use a newer version of library Foo in my testCompile, but it's causing a conflict when I run tests in intelliJ, as intelliJ is defaulting to using the older Foo lib.

I've tried excluding Foo, and then explicitly including it in testCompile, but it seems the exclude overrides the include in testCompile.

I'm currently using the below to force a resolution, but I would prefer I don't force compile dependencies to a specific version.

configurations.all {
  resolutionStrategy {
    force 'org.foo:bar:1.0'
  }
}

Upvotes: 4

Views: 482

Answers (1)

Eric Wendelin
Eric Wendelin

Reputation: 44369

You might consider configuring idea.module.scopes.TEST like so:

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

and then running gradle cleanIdea idea. You could also consider modifying the testClasses configuration such that the old version is excluded.

Upvotes: 0

Related Questions