How Gradle Handle libraries (specifically jetpack compose)?

i am new to Gradle and i want to know about how gradle handles libraries (resources, manifest, R.txt, classes.jar and other files) and how to use them during build.

generally, we use aapt2 for compiling and linking but before that when we have multiple resources like from libraries (AAR Files) and then our project resources, how to combine them all and then re create final files to use in the project for successful build.

Asking about background implementation and how can we implement same steps using command line (only want to know process and will implement in cmd)

If someone Experienced in this field, then please help me…