Reputation: 2219
I am using the following code:
java.sourceSets["main"].java {
srcDir("src/main/extraSource")
}
works perfectly in gradle 4.9, but in 4.10 rc1 gives the following error:
Line 5: java.sourceSets["main"].java {
^ 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
Any ideas? Has there been a change to what is needed? Many other answers (eg. this one and every suggested answer to this question) will also need updates if this has changed
Upvotes: 8
Views: 1768
Reputation: 4434
This is an expected breaking change and is listed at https://docs.gradle.org/4.10-rc-2/release-notes.html#changes-to-the-gradle-kotlin-dsl
But unfortunately it's missing in the Kotlin DSL release notes, it'll be fixed for 4.10 GA.
In a nutshell, java.sourceSets
is now sourceSets
. For your example the fixed script is:
sourceSets["main"].java {
srcDir("src/main/extraSource")
}
It’s a change in gradle/gradle
, see https://github.com/gradle/gradle/pull/5867 for some background.
Upvotes: 12