Hi I am trying to declare dependencies on the test...
# community-support
j
Hi I am trying to declare dependencies on the test code of another subproject. in
project1
I got
Copy code
task testJar(type: Jar) {
  dependsOn classes
  archiveClassifier = 'tests'
  from sourceSets.test.allSource
}

tasks.named('assemble').configure {
  dependsOn 'testJar'
}

configurations {
  testArtifacts
}

artifacts {
  testArtifacts testJar
}
then in
project2
Copy code
testImplementation project(path: ':project1', configuration: 'testArtifacts')
but during build those dependencies cannot be resolved. What is the recommended way to do this? I am on
7.6.2
v
Besides that you should probably use the test fixtures plugin as advised, you package
allSource
into the jar, that is the source files and thus you cannot use the classes of course. Also iirc
classes
depends on the tasks that compile production sources,
testClasses
depends on the tasks that compile test sources. And that you think you "need" that explicit dependency is also already a strong sign, that you do something wrong. Basically any explicit
dependsOn
that does not have a lifecycle task on its left-hand side is a code smell and usually means something is wrong.