Are dependencies on jars with classifier tests transitive?


(Simon Østengaard) #1

I have declared the dependencies of project2 like this:

dependencies {
  testCompile('com.company:project1:1.0.0-SNAPSHOT:tests')
}

and the dependencies of project3 like this:

dependencies {
  testCompile('com.company:project2:1.0.0-SNAPSHOT:tests')
}

Project3 test classes extends project2 test classes that extends project1 test classes. However I get an error during the compileTestJar task of project3 that it can’t locate code from project1.

The project1 test jar also seem to be missing from the dependency tree when I run the dependencies task for project3.

Is there a way I can get these dependencies on tests classifier jars to be transitive?


(Peter Niederwieser) #2

You are using external Maven dependencies here, rather than Gradle project dependencies within the same build. I can’t think of a good way to make transitivity of test dependencies work with Maven modules (neither when using Gradle nor when using Maven), except by having separate Maven modules for shared test code. Maven’s ‘test’ scope is not transitive by design, and Maven classifiers are rarely the solution to anything. (The classifier gives you a different artifact, but the POM, and therefore dependencies, stay the same.)


(Simon Østengaard) #3

That makes sense. Thanks.