Wasf
(Wasf)
November 22, 2018, 1:53pm
1
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.
Lance
(uklance)
November 25, 2018, 12:35am
2
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.
Wasf
(Wasf)
November 25, 2018, 4:57pm
3
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.
Lance
(uklance)
November 26, 2018, 12:11am
4
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.
Wasf
(Wasf)
November 26, 2018, 7:40am
5
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
Lance
(uklance)
November 26, 2018, 9:38am
7
Yes, looks like kotlin-dsl is invoking the DefaultSourceDirectorySet
constructor via reflection
private val createDefaultSourceDirectorySet: (name: String?, resolver: FileResolver?) -> SourceDirectorySet = run {
val klass = DefaultSourceDirectorySet::class.java
val defaultConstructor = klass.constructorOrNull(String::class.java, FileResolver::class.java)
if (defaultConstructor != null && defaultConstructor.getAnnotation(java.lang.Deprecated::class.java) == null) {
// TODO: drop when gradle < 2.12 are obsolete
{ name, resolver -> defaultConstructor.newInstance(name, resolver) }
} else {
val directoryFileTreeFactoryClass = Class.forName("org.gradle.api.internal.file.collections.DirectoryFileTreeFactory")
val alternativeConstructor = klass.getConstructor(String::class.java, FileResolver::class.java, directoryFileTreeFactoryClass)
val defaultFileTreeFactoryClass = Class.forName("org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory")
val defaultFileTreeFactory = defaultFileTreeFactoryClass.getConstructor().newInstance()
return@run { name, resolver -> alternativeConstructor.newInstance(name, resolver, defaultFileTreeFactory) }
}
}