How to specify a test dependency of a subproject with the Kotlin DSL?


I’m using Gradle 5.1.1

My project has a testCompile dependency to another subproject test dependency.

The following code line works fine with the Groovy DSL:


However, if I use the same line with the Kotlin DSL, I get the following error:

Build file ‘C:\Users\guru\development\yass\kotlin\build.gradle.kts’ line: 143

* What went wrong:
Script compilation error:

  Line 143:         testCompile(project(":kotlin:yass").sourceSets.test.runtimeClasspath)
														^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
															public val Project.sourceSets: SourceSetContainer defined in org.gradle.kotlin.dsl
															public val KotlinJvmProjectExtension.sourceSets: NamedDomainObjectContainer<DefaultKotlinSourceSet> defined in org.gradle.kotlin.dsl

Any ideas what I’m doing wrong would be very much appreciated.
How could I fix this?


Note: You can find my build script at

1 Like