In a multi-module project, with Groovy, I can have...
# gradle
f
In a multi-module project, with Groovy, I can have a base gradle file that is imported into other files, using
apply from: "$rootDir/base_library_module.gradle"
- is there something equivalent with Kotlin DSL for
build.gradle.kts
?
j
precompiled plugins
f
thanks, I'lll look into this, but a quick search would indicate this is quite a bit more involved that the
apply
solution for Groovy
so not really equivalent, if I'm understanding this correctly
h
Afaik you can do exactly the same with kotlin files. Just Pass them in there.
f
How do you "pass" them?
b
apply(from= “path/to/abc.gradle.kts”)
j
Not sure tbh,
apply from
looks like an antipattern for me
I would use precompiled plugins instead
f
@Benoît Liessens thanks, that's the syntax I was after
v
Script plugins are non-idiomatic for both DSLs. Better use precompiled script plugins, they are not really "more involved". And especially for Kotlin DSL precompiled script plugins are better, because in normal script plugins you don't get accessors generated.
e
with Gradle Kotlin DSL, there are some limitations for script plugins. standalone script plugins: 1. Type-safe accessors - N 2. Function export - N (
extra["xxx"] = fun()
can be a workaround) 3. Extension Function export - N 4. Shared Dependencies - N (You need to redeclare
buildScript{}
) precompiled script plugins: 1. Type-safe accessors - Y 2. Function export - N (
extra["xxx"] = fun()
can be a workaround) 3. Extension Function export - Y (
fun Project.customLog(…){…}
) 4. Shared Dependencies - Y (By
build.gradle.kts
of
buildSrc
or a standalone project) So it’s not an equivalent of Gradle Groovy DSL script plugin, but again “Better use precompiled script plugins” same as Vampire’s opinion.