I am asking this question because I actually want to pull in all the compile time dependencies of project A into the testCompile dependency of project B and I can’t figure out how to do that. I assumed testCompile project(path: “projectA”, configuration: “compile”) will work, but it doesn’t.
I consider project(":projectA").sourceSets.main.output to be bad practice since I feel that the sourceSets of another project are private. Much better to define a configuration in the project and reference that instead.
project(":projectA") is equivelant to project(path: ":projectA", configuration: "default"). More info on the default configuration here
Take a look at the “Project dependencies” section in the DependecyHandler documentation here for more info on the project(...) method.
I have gone through a decent amount of documentation, but I just couldn’t understand one thing -
Will project(path: “projectA”, configuration: “compile”) automatically place project(":projectA").sourceSets.main.output on the compile classpath of test code in Project B? What else will it have? Will it also bring in the entire compileJava Classpath of Project A?
project(":projectA").sourceSets.main.output is a reference to the outputdirectory(s) so will not bring in the transitive dependencies. By default, testCompile project(":projectA") will also bring in the transitive dependencies. You could avoid this via