Chih
Chih

Reputation: 105

How to convert sourceSets from a project to kotlin kts

I have a multi module gradle project. I'm converting all build.gradle configuration files to Kotlin kts.

But I can't find how to convert this code below to kotlin kts.

I tried to place groovy code inside kts and checked the documentation, but I could't find anything.

    testCompile project(":entities").sourceSets.test.output

Upvotes: 2

Views: 1657

Answers (2)

Can Bezmen
Can Bezmen

Reputation: 122

This also works for me.

dependencies {
    testImplementation(project(":entities").dependencyProject.sourceSets["test"].output)
}

Upvotes: 2

Mark Brodziak
Mark Brodziak

Reputation: 156

After some investigation, I found that the syntax in this area has changed recently.

I tried a few variants, and discovered that:

dependencies {
  testImplementation(project(":entities").sourceSets["test"].output)
}

results in

testImplementation(project(":entities").sourceSets["test"].output)
                                     ^ 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

But the following works just fine, as long as the Java plugin is enabled:

val entityTests: SourceSetOutput = project(":entities").sourceSets["test"].output

dependencies {
  testImplementation(entityTests)
}

Upvotes: 2

Related Questions