Hi, I'm wondering if there are any best-practises ...
# build-tools
l
Hi, I'm wondering if there are any best-practises or points to think about when deciding how much or when to modularize a project into multiple build files (maven modules, gradle subprojects). Does anyone have any good advice for when, and how to decide what to break up into different build modules?
a
a few use cases come up to my mind 1. you use different jvm languages and need different compilers for different parts 2. move slow integration/e2e test suite into separate module and only run it on CI 3. you need to pack jar artifacts in a different way or they have different lifecycle and deploy process (e.g one is library, yet another is dockerised app)
a
my 2cents: modularization helps with maintaining control over codebase by isolating dependencies in monolithic module, one can access pretty much everything except private (in kotlin there is no package-private) which over time results in unwanted dependencies between code modules can help you define borders more clearly, in Gradle/Buck/Bazel you can also specify more precise visibility for transitive dependencies
api/implementation
, in Buck & Bazel you can go further and specify visibility of module for other modules
👍 1
as a side-effect of modularization you might get faster builds as well as slower, ie our project has 771 modules as of right now and Gradle suffers from this a lot, Buck however is fast
🤔 1
j
@eriwen You might have some input worth sharing as well. My opinion on this is that having a bunch of smaller projects means that build tools like Gradle can be massively parallelized which is awesome. All of our project's tests can be run in parallel on a developers machine and in CI by just laying out your project correctly. I don't have much to say about Maven besides that it's build lifecycle is pretty much linear which means you can't really parallelize it. Gradle on the other hand uses the Directed Acyclic Graph (DAG) for your tasks to determine task relationships and figures out what tasks can be run in parallel with one another. I can't speak about Buck.
a
to be fair, you can run tests in parallel without modules in Gradle
h
@artem_zin Could you elaborate on why exactly gradle is slow for you? Initializatoin, Configuration, Intellij is slow? Not a lot of projects in the wild with that many modules to compare.
h
But it's android modules though, more heavyweight than general `java-library`/`kotlin` module. 20 seconds is for build configuration or `sync`/`help` configuration?
Also are your modules kotlin or java?
a
mixed, most still java, a lot of them are plain java without android plugin