As a preface to this question, let me first say that we are complete newbies to Gradle. We’re migrating our Java project from Ant to Gradle, and trying to follow Gradle conventions as much as possible. We’ve got a multi-project/multi-module configuration.
RE: Gradle 2.6, Mac OS X, Java 1.8_45
For simplification purposes, let’s say we have just two projects, let’s call them util and scheduling where scheduling depends on the util project. We have classes in util/src/test upon which class in scheduling/src/test depend. In the scheduling/build.gradle file, we have a the following dependency: “compile project (’:util’)”. However, even with this dependency, Gradle does not seem to automagically resolve the test dependencies across the projects. I’ve tried to follow the solution in this other post, Dependencies defined with project(’:projectname’).sourceSets.test.output are not transitive, but it is not working for me. Specifically, even with the recommended changes in that post, I still encounter compile time failures where test classes in scheduling are failing to compile, because they cannot resolve test classes from util.
The biggest problem I’m having right now is that I have no idea where to even start with debugging this issue. I’m compiling with --debug, I see the compileTestJava for my scheduling project, and I see that it does not include any class or sourcepath reference to my util project’s test classes, but I have no idea why. In reviewing the output, it appears that Gradle is attempting to execute scheduling:compileTestJava before util:testJava, and, again, I have no idea why.
Generally speaking, I’m happy with Gradle when it works, but I’m very frustrated that I do not even begin to understand all the automagic functioning or even how to discover what it does for you automatically. If anyone can at least offer this newbie some advice (e.g. teach a man to fish) on how I can figure out the answer to this question and, in the process, better learn how Gradle works and how to debug problems when everything is not working, I would greatly appreciate it.