Added 'java-test-fixtures' plugin, now tests can't find sources

Background: I was trying to move classes which we use from tests configurations into testFixtures, in order to speed up the build by having less shared code on the classpath, running doc generation only on testFixtures instead of all test classes, etc. So I moved the classes from src/test to src/testFixtures, added the ‘java-text-fixtures’ plugin, and built - and the compilation failed. But the weird thing was, the class it couldn’t find was one of the main classes in the very same module that was being tested.

I was trying to do this all in one go for the entire project though, so I didn’t have a good sense of where it broke. So now I’m investigating the cause.

Right now I’m here:

  1. Start from a working commit. (check passes)
  2. Add just the plugin, at this point:
    // ... some more above ...
    allprojects {
        apply plugin: 'java'
        apply plugin: 'java-test-fixtures' // <- Added just this
        apply plugin: 'com.acme.gradle.plugins.common' // our own common plugin
    // ... a lot more below ...
  3. Try to run :acme-common:compileTestJava

To my surprise, this fails, and I haven’t even moved around any sources yet, I’ve just applied one more plugin.

So where should I be looking next? What exactly does this plugin do when it is applied?

I’m guessing that there is some conflict with another plugin, potentially our own common config one, but I have no idea what to look for.

Here you can see exactly what it does: gradle/ at v7.4.0 · gradle/gradle · GitHub

Maybe the latter is causing your problem?

We have set compile configurations not to be transitive to avoid other problems.

So test depending on testFixtures doesn’t automatically mean that the main classes end up on the classpath in general, and yeah, it looks like that workaround breaks it for our case.

Removing duplicate entries from the classpath seems like a valid thing to do, but that change doesn’t appear to be a good way to do it. :frowning:

I suggest you open an issue on GitHub then to get this discussed with and maybe fixed by the Gradle folks, or a PR right away if you have a better alternative.