Ppl, do you know if I can import a `.gradle.kts` file inside a `.gradle` file?
a
Ppl, do you know if I can import a
.gradle.kts
file inside a
.gradle
file?
k
I don't think the two can go exist. I was slowly trying to move over to kts but I couldn't import older gradle files. Ended up having to convert all files
h
can i import
.gradle.kts
functions and use it inside a
.kt
?
r
You tried
apply(from = ...)
?
t
migrate it to convention plugin
h
Dont know aaaaabsolutely for sure but it might be just as simple as using apply from early enough, similar as described here https://docs.gradle.org/current/userguide/kotlin_dsl.html#using_a_groovy_script just the other way around. We used it the other way around a lot, so i expect that to just work.
e
You can apply a script from another one whatever the language.
From a
.gradle
script:
Copy code
apply from: 'path/to/script.gradle.kts'
From a
.gradle.kts
script:
Copy code
apply(from = "path/to/script.gradle")
👍 2
There are caveats when applying a kotlin script from a groovy one with regards to dynamic vs. static languages though. Groovy dynamism that rely on reflection allows you to do a lot of things that are illegal in a statically compiled language such as Kotlin. You’ll face unresolved references and may have to rely on reflection. See this section of the manual for more details and some helpers: https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:interoperability
💯 1