Issue with source set in IntelliJ

Hi.

I am dealing with multi-project builds. In project A I have a helper class that is used by test classes in the same project as well as test classes in another project B. All good. When I use the helper class from project A in a main source class in project C I get a compile error in IntelliJ. Gradle build works fine though - after adding the following to the build.gradle file of project C:

sourceSets {

main {

compileClasspath += project(’:’).sourceSets.test.output

}

test {

compileClasspath += project(’:’).sourceSets.test.output

} }

Any idea, what I could do to get rid of the compilation issue in IntelliJ (version 12.0)? I appreciate your help.

Are you saying that a production class in C uses a test class in A?

Yes. Rare situation, but that’s what we have here.

This can cause a lot of troubles - when deploying, in the Gradle build, in IDEs, etc. To give just one example, the new compiler in IDEA 12 no longer supports having a dependency from sources in module A on test sources in module B, and you’ll have to fall back to the old compiler. Rather than working around such problems, it’s better, and likely easier, to fix the root cause.

Hi Peter, Thanks for the immediate help - very useful information. I changed the structure, so we have no dependency on a test source anymore.

Have a good week.