Test class dependencies in multi project build

Hi Guys

I’m migrating from M3 to M9. I have dependencies in my projects on test classes from other projects. I used the method that Adam suggested in his post http://gradle.1045684.n5.nabble.com/Test-classes-as-testCompile-dependencies-in-Multi-Project-td1436001.html Building a test jar, and including it in the project. Somehow, it stopped working. I got failures when I try to compile test classes. It looks like something changed I assume in this space. What would be the preferred way of going about that problem in M9?

Cheers, Greg

Hi Greg,

Can you please give some information on how it failed, and share the relevant parts of your build.

Hey Luke It didn’t fail with error. It failed with compilation errors, just like it didn’t include the compiled classes in testCompile dependency. Once again I need to stress out that the approach was done with the suggestion in post mentioned by me in original post.

Is there a preferred way of including test classes compiled from one project into another?

Cheers, Greg

I can’t see any reason why this would not work.

Can you please post an illustrative build setup that:

  1. matches your setup 2. demonstrates the problem

Hi Luke Structure is somewhat like the one in the here: https://github.com/greggigon/gradle-tests

However, that one doesn’t fail. I need to investigate more into it. Will let you guys know when I find out.

The only changes I needed to make for the M9 is the way test jar is being build. Had to change:

task testJar(type: Jar) {

from sourceSets.test.classes

classifier = ‘test’ }

into task testJar(type: Jar) {

from sourceSets.test.output

classifier = ‘test’ }

Cheers, Greg