Gradle test classes needed in another sub-project

Hi,

As explained here, a ProjectDependency is a dependency on the default configuration of a particular project.

For a java project, the default dependency is an extension of the runtime dependency (as stated in here).

In your case, you want to depend on the testRuntime dependency, with something like compile project(':A:B:C', configuration: 'testRuntime')

If this doesn’t suit you, you can always create a custom configuration, and depend on it:

in :A:B:C project:
configurations{ fooConf }
task testJar(type: Jar){ from sourceSets.test.output }
artifacts { fooConf testJar }

in :A:G:X project:
dependencies { compile project(':A:B:C', configuration: 'fooConf')
1 Like