Jendrik Johannes
04/25/2024, 8:44 AMbuild.gradle(.kts) file, we end up with a file of several 100 lines for some projects. Which is not practical. Therefore, we want to split up the configuration. In our build system, we have concept called "*process*" which corresponds to one or more Gradle tasks. A project can have several 100 of these processes. We want to have one configuration file per process. How do we achieve this best? Here is what we tried/do now:
• Using pre-compiled script plugins is not an option. The files are something developers work with regularly. Changing a configuration cannot invalidate the whole build. Which pre-compiled script plugins do, as changing them changes the plugin classpath.
• We started using Kotlin DSL for good IDE support in IntelliJ for our custom DSL/extension.
• But for the split-up, the only option we found is "traditional" script plugins in Groovy DSL. Now we have a mix of build.gradle.kts (Kotlin) and .gradle (Groovy) script files.
◦ (Is there a way to use the Kotlin DSL here with a custom extension? I think there isn't right?)
• Many developers will probably use VS Code as they use it for the actual development as well. And the Kotlin DSL support is not good here, which weakens the argument for Kotlin DSL in general.
I am not happy with the mixed DSL situation we have right now. The only "acceptable" solution I see right now is moving completely to Groovy DSL. But also there the IDE support is bad even in IDEA. Our custom extension is not recognized in the script plugins (.gradle files). I am not very satisfied with the solution because of that. And I wonder if there is any other alternative I am missing.Paul Merlin
04/25/2024, 8:47 AM(Is there a way to use the Kotlin DSL here with a custom extension? I think there isn't right?)The Kotlin DSL doesn't generate accessors to extensions in applied scripts because it can't know for sure they will be present.
Paul Merlin
04/25/2024, 8:56 AMconfigure<ExtensionType> {
myProp = "value"
}
The main issue is that types from buildSrc won't be visible in these scripts in IDEs (only types from gradleApi() are).
You would need to publish an artifact with the extension type and add the buildscript {} dependency to each of these scripts.
Not a good solution at all, but that's how it could be possible 😕Paul Merlin
04/25/2024, 8:57 AMJendrik Johannes
04/25/2024, 9:46 AMconfigure<ExtensionType> {
myProp = "value"
}
This may be a good compromise. I'll try and see how well it works in the IDEs. (buildscript {} part should not be an issue, we do not use buidSrc, but publish in any case to share our "build system" across all projects. And we have settings plugin to control such things if needed).Jendrik Johannes
04/25/2024, 9:49 AMDid you consider using external files in other formats?Yes we thought about it but did not really consider it as an option. At least for now. A "Gradle DSL" allows us to quickly iterate as it is simple to define and change (once you know how things work). It'll take time to get to a first "stable state". Once we are there, we might reconsider. But if the IDE support is okaish with the Gradle DSL, I would like to stick with it. It's a big advantage in my mind.
Alex Semin
04/26/2024, 9:03 AMJendrik Johannes
04/26/2024, 10:54 AMAlex Semin
04/26/2024, 1:31 PMJendrik Johannes
04/30/2024, 11:52 AMconfigure<> workaround! 💚
Do you know how well IDEA support for this is/was. I am seeing the following. At first I though that it can't work if for IDEA these are just files without context. But then, if IDEA gets all the "configuration events" from Gradle, it could actually work. 🤔 Do you know if this ever worked?Paul Merlin
05/02/2024, 2:46 PMJendrik Johannes
05/02/2024, 3:10 PMJendrik Johannes
05/02/2024, 3:11 PMJendrik Johannes
05/02/2024, 3:11 PMJendrik Johannes
05/02/2024, 3:12 PMbuildscript {
repositories {
maven("repo-with-my-plugin-and-my-plugins-dependencies")
}
dependencies {
classpath("my.plugin:coordinates:1.0")
}
}Jendrik Johannes
05/02/2024, 3:13 PMPaul Merlin
05/02/2024, 3:13 PMJendrik Johannes
05/02/2024, 3:15 PMJendrik Johannes
05/03/2024, 6:59 AMPaul Merlin
05/14/2024, 9:47 AM