# Optimizing Gradle Builds in Multi-module Projects

DevFeed: [Optimizing Gradle Builds in Multi-module Projects](<https://devfeed.tech/articles/optimizing-gradle-builds-in-multi-module-projects-24719.md>)

Original publisher: [Read original article](<https://dev.to/touchlab/optimizing-gradle-builds-in-multi-module-projects-3ijp>)

Author: Jigar Brahmbhatt

Published: 2023-10-16T20:31:31Z

Content type: tutorial

Language: en

Sources: [Touchlab](<https://devfeed.tech/sources/touchlab.md>)

Topics: [Gradle](<https://devfeed.tech/topics/gradle.md>), [build times](<https://devfeed.tech/topics/build-times.md>), [build performance](<https://devfeed.tech/topics/build-performance.md>), [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Cache](<https://devfeed.tech/topics/cache.md>), [ci](<https://devfeed.tech/topics/ci.md>)

Tags: [android-studio](<https://devfeed.tech/tags/android-studio.md>), [build-performance](<https://devfeed.tech/tags/build-performance.md>), [build-times](<https://devfeed.tech/tags/build-times.md>), [cache](<https://devfeed.tech/tags/cache.md>), [ci](<https://devfeed.tech/tags/ci.md>), [coding](<https://devfeed.tech/tags/coding.md>), [community](<https://devfeed.tech/tags/community.md>), [development](<https://devfeed.tech/tags/development.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [inclusive](<https://devfeed.tech/tags/inclusive.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlinmultiplatform](<https://devfeed.tech/tags/kotlinmultiplatform.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [software](<https://devfeed.tech/tags/software.md>), [tech-debt](<https://devfeed.tech/tags/tech-debt.md>)

## AI overview

A practical guide to improving Gradle build times in multi-module Kotlin Multiplatform projects. It recommends benchmarking with the build cache disabled, using Gradle Build Scan and Android Studio Build Analyser, addressing legacy configuration such as Jetifier, and enabling parallel builds. The authors report more than a 50% speed improvement for a client with over 100 modules.

## Source excerpt

You're not alone if you've also struggled with sluggish Gradle builds in a multi-module project. Recently, we undertook the challenge of significantly reducing build times for a client with over 100 Kotlin Multiplatform modules, and achieved a more than 50% boost in speed across platforms. In this post, we'll walk you through the steps we took. We hope it proves valuable to fellow developers facing similar challenges. Benchmark Your Builds Before diving into optimizations, it's crucial to understand the baseline. Gather build times from all team members, ensuring the Gradle build cache is disabled. Use handy --no-build-cache option to any Gradle task command to run without build cache. Unsurprisingly, in our case, the Intel-based mac machines were really slow compared to Apple chip ones and we didn't have anyone with a Windows machine. This information is key for later comparison and improvement assessment. Note: One thing we realized that, some optimizations below might be more applicable to legacy or tech-debt-laden projects. Tools for Insight Gradle Build Scan Utilize the power of Gradle Build Scan to delve into the details of your builds. In my opinion, it's not just a diagnostic tool; it's a learning tool. In our case, we uncovered insights into the sluggishness of ios link tasks in the Kotlin Multiplatform setup. Comparing build scans on different CI machines helped identify the fastest configuration for a machine to use on our CI. Enabling parallel builds and analyzing the results through build scan reports further validated our improvements. Android Studio Build Analyser Android Studio provides a built-in analyser tool. It inspects build performance and provides warning around potential issues. Disable Jetifier Using this, we noticed the lingering android.enableJetifier=true usage due to outdated Picasso library that didn't use AndroidX libraries. That might have hindered build speed too. Addressing this involved updating Picasso and removing the jetifier fl