My company has a large number of gradle modules in...
# gradle
s
My company has a large number of gradle modules in a monorepo, and we've noticed that ios multiplatform modules seem to be particularly expensive. We love the simplicity that a monorepo brings, but our gradle syncs are running too slowly, our IDE's indexes taking too long, and peoples computers are running out of memory. We are leaning into separating our apps into completely separate gradle projects, but we're left still needing to be able to share code between the projects in a convenient way. Right now we're moving towards including modules by going into the parent directory and adding them in our settings.gradle.kts file. This means that multiple gradle projects share the exact same modules on disk. I feel like we can't be experiencing problems that other people aren't experiencing. Are there any other solutions that people have found for gradle mono-repos??
t
Sounds like you should be using composite builds. Example
v
This question has nothing to do with Kotlin and thus is actually off-topic here. Please always consider channel topics in communities. 😉 But regarding the question, never ever ever ever ever ever include one project into multiple builds if that is what you meant. One project should always belong to exactly one build. As Tim said, composite builds are what you should use. Also this might be interesting for you: https://github.com/jjohannes/idiomatic-gradle
s
I've been on a team that used a lot of composite builds before. Composite builds just exacerbated the problem, making things slower.
never ever ever ever ever ever include one project into multiple builds if that is what you meant.
I understand the point, but it seems to be the only way we can reasonably share modules of code. The only alternative I can think of would be to separate each project or super small groups of projects into builds and include them, but again, that seemed to slow things down.
v
I understand the point, but it seems to be the only way we can reasonably share modules of code.
No, it is not reasonable at all. Don't do it, or you get into all sorts of trouble. This is highly fragile and you should never, ever, ..., do that. If you need something like that, use composite builds, or you get into serious trouble sooner or later. Sometimes in obvious ways, sometimes very subtle.
s
ok
I mean, you are right of course. I'm just now sure how to make gradle scale
v
You might also be interested in https://developer.squareup.com/blog/herding-elephants/ and https://developer.squareup.com/blog/stampeding-elephants/. I'm not sure about the quality of the content, as I didn't read those articles yet, but I heard good things about them. 😄
s
thank you
👌 1