1. ProjectA build.gradle
task testsJar(type: Jar, dependsOn: testClasses) { classifier = 'tests' from sourceSets.test.output } configurations { tests } artifacts { tests testsJar archives testsJar } jar.finalizedBy(testsJar)
2. ProjectB build.gradle
dependencies { compile project(':projecta') testCompile project(path: ':projecta', configuration: 'tests') }