If your IDE is Android Studio ,there is a simple way.Just choose the module folder you want to compile ,then click Build and choose Make Module 'your module folder'.
In Android Studio, if you need to generate a signed bundle or apk, you can choose the needed module in Module select field: Build > Generate Signed Bundle or APK > choose Android App Bundle or APK > Module