This message was deleted.
# community-support
s
This message was deleted.
m
out of curiosity, what are the limitations you're talking about?
i
sigh, 😄 I kinda hoped I would get the answer first before I will have to explain - but this was expected we would like to organize our scripts by using Groovy
apply-from
with scripts, projects contains at least 30+ modules and is growing, we would like to share as much code as possible, the way you work with
apply-from
is to create base script file and then then extend is with more specialized ones the only way I found to to mimic that in KTS is by using functions defined in
buildSrc
something like that
Copy code
private fun Project.moduleJvm() {
    moduleBase()

    // Uniform way of configuring Kotlin tasks in all Kotlin modules
    tasks.withType<KotlinJvmCompile>().configureEach {
        kotlinOptions.jvmTarget = KotlinConfig.jvmTarget
    }
}
Where functions are calling one another, from more specialized one to basic one Maybe "limitation" is not a best word, but this approach makes things very cumbersome with comparison to Groovy approach with apply-from. More or less that's it
m
Can't you do the same with plugins?
I wrote very simple plugins and then you can have a hierarchy when you have a base plugin and more specialized ones
i
Can I force other plugins in my plugin?
m
Yes
and that's how I do it exactly
the more specific plugin applies the base plugin
which has more generic settings
That's why I asked the question, because maybe Kotlin is not the source of your worries 😉
e
whether it's Groovy or Kotlin DSL, plugins are the intended solution.
1
☝️ 2
v
And if you use precompiled script plugins, you can even write them almost like normal build scripts.
i
Well, I don't see why not, I haven't seen this approach suggested but still, I used
apply-from
approach in previous company and main benefit of that was syntax, teams understood it right away and plugins were not required - but I will take a look at plugins
v
As I said, if you use precompiled script plugins, the syntax is basically identical and it is the recommended approach. Normal script plugins (thing you use with
apply from:
are long discouraged already in favor of convention plugins which are most often implemented as precompiled script plugins.
j
apply from will be deprecated?
a
For Groovy vs Kotlin: there are no plans at all to drop Groovy. For sharing build logic additional to what other said you might want to check this sample: https://docs.gradle.org/current/samples/sample_convention_plugins.html. It codes as a build script, it works as a plugin.
👍 1
j
I would like to be a massive reorganization of Gradle in 8.0-10.0 by deprecating/removing legacy patterns and setting as default the new patterns
multiple of them would need drop the legacy implementation and replace with the new one using the same APIs but being lazy, and that is hard to do without a lot of breaking changes
v
apply from will be deprecated?
Not that I'm aware of. I said it is discouraged, not deprecated.
e
apply from
does work with Kotlin DSL same as Groovy, you just get zero generated type-safe accessors. whether you stick with Groovy or Kotlin you should change them to plugins. as Björn mentions, it is easy to just copy-them into precompiled script plugins. and then you get generated type-safe accessors and all that.