mbonnin
08/03/2023, 10:40 AMReplaceWith
deprecated substitutions are not working in build.gradle.kts
? Trying to migrate to Gradle 8.3 that deprecates project.buildDir
, I can't get the quick fix to workJavier
08/03/2023, 10:44 AMJavier
08/03/2023, 10:44 AMbuildDir
was going to be deprecatedmbonnin
08/03/2023, 10:46 AMmbonnin
08/03/2023, 10:47 AMVampire
08/03/2023, 10:47 AMmbonnin
08/03/2023, 10:48 AMProject
Vampire
08/03/2023, 10:48 AMReplaceWith
a thing in Java?mbonnin
08/03/2023, 10:49 AMmbonnin
08/03/2023, 10:49 AMmbonnin
08/03/2023, 10:50 AMReplaceWith
is also slightly unexact, filed thisVampire
08/03/2023, 10:53 AMJavier
08/03/2023, 10:54 AMmbonnin
08/03/2023, 10:56 AMasFile
my way until I get something that compiles ๐
mbonnin
08/03/2023, 10:56 AMPath
is the new File
though ๐คทVampire
08/03/2023, 10:56 AMProvider<File>
it is just not as expressive, as it is unclear whether it is a file or directory.Vampire
08/03/2023, 10:56 AMPath
, but yeah, Path
is preferable over File
in most cases tooJavier
08/03/2023, 10:57 AMVampire
08/03/2023, 10:57 AM.kt
file I do not get the a quick-fix to replacembonnin
08/03/2023, 10:57 AMVampire
08/03/2023, 10:57 AMVampire
08/03/2023, 10:58 AMmbonnin
08/03/2023, 10:58 AMmbonnin
08/03/2023, 10:58 AMMaybe it is because the definition of the method is in the Java interfaceAh yes, in a plain .kt file, it uses the
Project.java
API directlyVampire
08/03/2023, 10:58 AMProjectDelegate
is also declared deprecated o_OVampire
08/03/2023, 10:59 AMAh yes, in a plain .kt file, it uses theThat's why I castedAPI directlyProject.java
target
to ProjectDelegate
, so it does not use Project
Vampire
08/03/2023, 10:59 AMbuildDir
I land in ProjectDelegate
mbonnin
08/03/2023, 10:59 AMmbonnin
08/03/2023, 10:59 AMmbonnin
08/03/2023, 11:01 AMProjectDelegate
seems reasonable to me. Putting it back in scope is a simple project.apply {}
and it makes everything more explicit (and avoids accidentally resolving name
to the wrong receiver)mbonnin
08/03/2023, 11:02 AMProjectDelegate
do not show any warning though...mbonnin
08/03/2023, 11:02 AMVampire
08/03/2023, 11:02 AMVampire
08/03/2023, 11:03 AMProjectDelegate
you have fun getBuildDir()
.
So if you do getBuildDir()
, you get the replacement quick-fix also in kts filembonnin
08/03/2023, 11:03 AM'Build_gradle' is deprecated. Will be removed in Gradle 9.0
It's all going away ๐Vampire
08/03/2023, 11:04 AMfun getBuildDir()
in a Kotlin file, you cannot use buildDir
naturallyVampire
08/03/2023, 11:04 AMVampire
08/03/2023, 11:04 AMVampire
08/03/2023, 11:04 AMProjectDelegate
method actually nowVampire
08/03/2023, 11:05 AMgetBuildDir()
Vampire
08/03/2023, 11:05 AMmbonnin
08/03/2023, 11:05 AMgetBuildDir()
gets me a step closer fails for me in that specific case because it replaces with this.layout.buildDirectory.get()
but this
is not the ProjectDelegate
Vampire
08/03/2023, 11:06 AMmbonnin
08/03/2023, 11:07 AMThe getter-magic only works with Java interopNot sure I follow, how come I can write this in Kotlin if there is no Java involved ๐ค
// calls ProjectDelegate.getBuildDir() under the hood
buildDir
Vampire
08/03/2023, 11:08 AMVampire
08/03/2023, 11:09 AMProjectDelegate
implements Project
mbonnin
08/03/2023, 11:09 AMVampire
08/03/2023, 11:09 AMgetBuildDir
is defined by Java and thus can be used with buildDir
Vampire
08/03/2023, 11:10 AMmbonnin
08/03/2023, 11:10 AMgetBuildDir()
Not sure about the secondVampire
08/03/2023, 11:11 AMthis.
when it shouldn't while replacing)mbonnin
08/03/2023, 11:11 AMmbonnin
08/03/2023, 11:11 AMmbonnin
08/03/2023, 11:47 AMmbonnin
08/03/2023, 11:48 AMmbonnin
08/03/2023, 11:48 AMmbonnin
08/03/2023, 11:49 AM@Deprecated("Deprecated", ReplaceWith("helloo"))
fun hello() {
println("hello")
}
fun helloo() {
println("helloo")
}
fun main() {
hello()
}
Vampire
08/03/2023, 12:09 PMReplaceWith("helloo()")
it worksmbonnin
08/03/2023, 12:47 PM