How to avoid cross-project configuration without buildscripts?

According to idomatic-gradle, subprojects and allprojects should be avoided to prevent cross-project configuration.

I have been taking a unique approach lately. I do not use buildscripts. I only have a single settings.gradle.kts file in my root project. In it, I call:

  gradle.rootProject {
                       // this is the my "main" method for all of my gradle code.

Is this ok? Does this avoid cross-project configuration? If not, how can I avoid cross-project configuration without writing individual buildscripts for each project?

Not having individual build scripts for each project is exactly non-idiomatic.
The individual build scripts for the projects can end up to only applying one convention plugin and maybe define some dependencies.
But the idiomatic approach is, that you have a build script for each project and that it applies everything that should be valid for that project, even if it is only one convention plugin.
Then you can instantly see from that build script what defines that project or where to look for the implementation details.
If you do cross-project configuration like also your approach is doing, you have to know where to look at for what defines the build logic and thus, besides the technical problem of doing cross-project configuration, makes builds harder to understand and harder to maintain.

@Vampire thanks for the answer.

I understand that my approach is not idomatic in that way. Actually, I created my own system where each subproject has a “build.json” file that contains any necessary info such as dependencies and plugins to use. My Gradle code reads these json files and configures the build accordingly. I have a project with over 100 subprojects and the time it was taking to compile all of the build.gradle.kts files (which sometimes only had a few lines of code) was getting absurd and this also greatly simplified my build for me. I can look at one of my “build.json” files to instantly know which plugins are applied.

I know that my approach likely sounds appalling to some, but its had great success for me. I’m mainly just interested in how I can get gradle to de-couple these projects and configure them in parallel without having to add “build.gradle” files again.

You might be also interested in Custom Scripting Language support · Issue #22793 · gradle/gradle · GitHub which would probably solve your problem in an elegant way.

1 Like

@Vampire yes! That’s exactly what I’d like to do! I will add a comment on that GitHub issue.