Library Development using Composite builds
Libraries have become an essential part of application development. There are millions of libraries in the market, some are public and some remain private to the organisation.
I will cut the chase and getting to important topic of this blog
There are many of blogs of how to set up a library project and how to host them in artifacts for application to download. This blog will only explain about how to save time in library development without hosting artifact again and again during library development phase using gradle composite build.
I will explain about effective library development in JAVA & ANDROID.
JAVA
Client Project
Path : /Users/bayetra/WorkSpace/clientone
Library Project
Path :/Users/bayetra/WorkSpace/libraryone
In Client Project all we have to modify is the settings.gradle file
rootProject.name = 'clientone' if( file('../libraryone').exists() ) { includeBuild('../libraryone') }
Now what we are trying to say here is show me the library project in the client project workspace only if the project exist in the path specified. Advantage of adding “if” condition is when your CICD pipeline is running on the client project, The client project would download the library hosted in artifactory.
Now as we are in development mode, let’s see the advantage of composite build
As you can see when the client project resolves the dependencies it would not download the library from artifactory but chose to pick the included project. This will help you to do the development quicker. Here we are not uploading the library jar to artifact for every small change, Once you are happy with the way the library code is written you can choose to deploy the jar to the artifactory
ANDROID
The concept of composite gradle do not change for android as composite build is simply a build that includes other builds
“Composite builds allow you to:
>combine builds that are usually developed independently, for instance when trying out a bug fix in a library that your application uses
>decompose a large multi-project build into smaller, more isolated chunks that can be worked in independently or together as needed”