Intellij IDEA gradle: how to find out which modules are loaded

In IDEA project, there is Load/Unload Modules dialog, which allows me to load some modules.
This information is saved in .idea\workspace.xml file.

image

I want to detect in build.gradle script which modules are currently loaded.

I tried searching for this info in rootProject or in idea objects, but I can’t find it anywhere.

Can someone advice how do I determine in gradle which modules are currently loaded?
Thanks

P.S. I actually want to use this in Android Studio project, but it should be same as in IDEA Ultimate.