How to override version only for test compile and running tests

In production, google cloud connector for jdbc is used and drags in a new version of guava. This version of guava does not work with latest selenium which is on an older guava. I am using guava in tests so I would like to at runtime use the older guava jar for selenium. I tried changing compileClasspath to testCompileClasspath(a complete guess) following this

That didn’t seem to work though. 2 questions

  1. How do I list configurations so I don’t have to guess and list them?
  2. What is the correct syntax for what I want above and can I just swap out compileClasspath to the something and what is that something?

This post is a copy of

Hi @deanhiller,

If I understand correctly, you want to define a different Guava version in testing. Then you can set a constraint on testImplementation. Which will reflect in test compilation and runtime.

dependencies {
  constraints {
    // or if you need to force a version down, you can make it strict: 
    // testImplementation("!!")

This is documented in the Java Library plugin docs:

There is no built-in task or something to show you all configurations.

1 Like