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

Hi

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:

testCompile(project(":kotlin:yass").sourceSets.test.runtimeClasspath)

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?

Thanks,
Angelo

Note: You can find my build script at https://github.com/softappeal/yass/blob/dev.gradle.kotlin.dsl/kotlin/build.gradle.kts

1 Like