Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sourceSets with gradle kotlin DSL in grade 4.10rc

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

like image 954
innov8 Avatar asked Aug 14 '18 01:08

innov8


1 Answers

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.

like image 132
eskatos Avatar answered Nov 03 '22 04:11

eskatos