EnjoyDependence: Full Build Acceleration Solution for Android Componentized Projects
Youzan’s EnjoyDependence Gradle plugin dramatically speeds Android full builds—cutting compilation of their 450K‑line, Kotlin‑heavy project from over 15 minutes to under three—by managing dependencies, publishing AARs, and swapping source modules with prebuilt artifacts without altering project structure, while remaining stable and easy to adopt.
This article introduces Youzan's Android full build optimization solution based on EnjoyDependence. The project background reveals that after years of development, Youzan Retail's Android project has grown to 450K+ lines of code (phone & pad), with Kotlin code accounting for 33%. Under such large-scale code volume, compilation has become a bottleneck, with full build taking 15+ minutes on MacBook Pro i5-8G.
The optimization goals include: reducing full build time from 15min+ to under 3 minutes, maintaining low intrusion without modifying project structure, ensuring solution stability without affecting developer productivity, enabling flexible integration with existing systems, and providing easy management with low learning curve.
EnjoyDependence is a Gradle plugin that provides dependency management, build publishing, and compilation time statistics. The plugin offers features including aar publishing, dependency management, automatic publishing, and integration with Android Studio via EnjoyManager plugin. The implementation involves hooking into Maven publishing flow to customize pom.xml generation and artifact collection, creating AndroidVariantLibrary as the core class for Maven publishing.
The dependency management system uses a Plugin-based approach with dynamicDependency domain object creation, dependency resolution, and dependency substitution. This allows switching between source code and artifact (aar) dependencies without modifying existing build scripts, achieving compilation acceleration by skipping compilation of certain modules.
After the first phase optimization, build time significantly improved - 25 modules can now be compiled within 3 minutes. The solution also addresses common challenges like transitive dependency version inconsistency, multi-version management, and module addition/deletion handling.
Youzan Coder
Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.