Output of jar task as a dependency

Noob alert here. I simply have a single task to produce a jar like this:

task contentJar(type: Jar, overwrite: true) { ... }

artifacts { archives contentJar }

How do I include the jar produced by the contentJar task as a testRuntime dependency?

I was able to define the dependency like this:
testRuntime fileTree(dir: 'build/libs', include: '*content.jar')

Is there a cleaner solution to this?