https://kotlinlang.org logo
Title
d

darkmoon_uk

04/24/2019, 12:09 AM
Sad that there is no option to generate a new project's Gradle files in Kotlin DSL, in Android Studio - this seems like a benchmark for adoption.
g

gildor

04/24/2019, 12:50 AM
Most of AS tooling related to build.gradle is not working with Kotlin DSL, even basic ones, like reimport of project which generates build.gradle near your build.gradle.kts, so I believe there is long path until they add it
2
a

Al Warren

04/24/2019, 3:24 AM
After you've done it a time or two on a new project it's not that difficult or time consuming. But the order of steps is important. I could never remember that so I documented the process as I went through it and wrote a gist to remind myself. https://gist.github.com/alwarren/28f292e59d241cea4c816eefff18d681
g

gildor

04/24/2019, 3:44 AM
tasks{
    val clean by registering(Delete::class) {
        delete(buildDir)
    }
}
registering<Delete>("clean")
Anyway, there is great official migration guide: https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/
r

rkeazor

04/24/2019, 10:45 AM
It's not ready yet.
g

gildor

04/24/2019, 12:48 PM
Kotlin DSL is pretty much fine now, but stable AS is still on IDEA 2018.*, some important fixes available only on 2019 Also I believe AS tooling is bigger problem than Kotlin DSL itself
a

Al Warren

04/24/2019, 3:30 PM
@gildor On the clean task, that was sort of the point I was trying to make in the gist notes where I mentioned things can be version dependent. I had a hard time even following documentation because of that. I had already tried
registering<Delete>("clean")
but it didn't compile for whatever reason at the time.
g

gildor

04/24/2019, 3:33 PM
oh, sorry, I meant
register<Delete>("clean")
a

Al Warren

04/24/2019, 3:33 PM
I think I tried that too. 🤣
g

gildor

04/24/2019, 4:03 PM
Hm, works for me
a

Al Warren

04/24/2019, 5:44 PM
Might have been a version specific thing at the time I tried it. Or maybe I was looking at wrong documents for the version I was using. Hard to tell.