Module dependencies in Gradle and tests

In IDEA, if module A depends on module B, all of module A (main and tests) will be available to B. I like this.

In Gradle, if the compile dependencies for B reference A, it will be available for the main code only, not tests.

This leads to needing to do a hack like:

testCompile project(':A').sourceSets.test.runtimeClasspath


The problem is that this leads to some very silly looking libraries in IDEA for the A->B dependency. Stuff that isn't needed at all.

My understanding is that this is a limitation of the Gradle tooling API (as seen in IDEA-115007).

Is there any change we could get a magic extension property we could set on projects to indicate what the IDEA module dependencies would be to work around this?

2 comments

Hi Peter,

In Gradle you may have dependencies like:

testCompile files('C://some/other/source/path')


Gradle Tooling API does not distinguish it from project specific dependency notation. That's why, there is no way to handle it properly in IntelliJ at the moment.

Vlad

0

Vlad ,

Understood.

I was just wondering if there could be a separate out-of-band indication to IntelliJ that the files are really a module dependency. Such as:

project(":a") {
     ext.intellijModuleDependencies = [':B']
}


Gradle doesn't look to be changing any time soon. It is very nice to use the built-in Gradle integration, but if this remains unsolved I might have to not use it in favor of having Gradle generate the IML files (where something like http://stackoverflow.com/questions/5144325/gradle-test-dependency/13140763#13140763 can be used to explicitly filter these instances)

-pete

0

Please sign in to leave a comment.