The DefaultSourceDirectorySet constructor has been deprecated

I start to test Gradle 5.0.rc-4 with Kotlin 1.3.10 with the sample found here:
https://github.com/gradle/kotlin-dsl/tree/master/samples/hello-kotlin

I changed the

…/kotlin-dsl-master/samples/hello-kotlin/gradle/wrapper/gradle-wrapper.properties

to be

gradle-5.0-rc-4-bin.zip

and the

build.gradle.kts plugins of Kotlin to be 1.3.10

When I execute

./gradlew build

it successfully build but with this

Configure project :
The DefaultSourceDirectorySet constructor has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory service to create instances of SourceDirectorySet instead.

How I use ObjectFactory here?

Thanks.

I can’t see any references to DefaultSourceDirectorySet in the hello-kotlin project you linked to (note: I’ve not yet tried kotlin myself)

If you specify --stacktrace at command line it should give a stack trace for the deprecation.

Yes @Lance, there isn’t any DefaultSourceDirectorySet in the example, but even when created the project using gradle init command and try to build the default generated Hello Kotlin project, it give that Warning.

Yes, and I suspect that the call to DefaultSourceDirectorySet constructor is somewhere deeper in your stack (possibly in kotlin-dsl?). I suggest that you specify --stacktrace at command line to identify the culprit.

When I use --scan it give me two deprecated , it appears in the plugins:
id("org.jetbrains.kotlin.jvm") version "1.3.10"

It’s appear kotlin jvm gradle plugin still use DefaultSourceDirectorySet

https://github.com/JetBrains/kotlin/blob/a44d70e79d06a5133b86470c749cc2d0bf870053/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultKotlinSourceSet.kt

Sorry, I can’t at this time use --stack trace

It’s --stacktrace

See Gradle CLI

Yes, looks like kotlin-dsl is invoking the DefaultSourceDirectorySet constructor via reflection

2 Likes