It looks like if I use the java-test-fixtures plugin in my java Gradle project, when IntelliJ imports it the IDE will always mark the src/testFixtures
dir as a Source Folder (visible in Module Settings, Sources tab).
Yet any dependencies I've added in my build.gradle
to the testFixturesApi
or testFixturesImplementation
configurations are imported into the IDEA project with a Scope of Test
(visible in Module Settings, Dependencies tab).
So when I go to build my Project, using the Project Build and run using setting of IntelliJ IDEA
instead of the default of Gradle
(visible in Settings -> Build, Execution, Deployment -> Build Tools -> Gradle), the builder can't find the deps from those testFixtures configurations and I get a bunch of package does not exist errors.
This behaviour can easily be reproduced after setting up a new java-library
project using the gradle init
wizard and adding the 'java-test-fixtures' plugin to it, then adding a dep to one of the test fixtures configuration and importing it in a java file in the test fixtures SourceSet, then switching the Build and run setting and clicking build.
I'm using Gradle 6.0 and IntelliJ 2019.3 BETA.
I've tried explicitly marking the testFixtures source dir as a Test Source folder:
idea {
module {
testSourceDirs += project.sourceSets.testFixtures.allJava.srcDirs
}
}
But the IDEA Gradle import doesn't seem to honor this, and I suspect it's the wrong solution anyway.
Is there any way to get the java-test-fixtures plugin to play nice with the IDEA builder without leaking my deps from testFixturesApi
configuration into the api
configuration?
UPDATE
So my team has enabled the "gradle.settings.showDeprecatedSettings" option in the IntelliJ registry and is currently NOT using the recommended "Module per SourceSet" option - instead we have a module per project. This issue only applies with module per project, which is deprecated. See: https://youtrack.jetbrains.com/issue/IDEA-222172