Gradle idea build is stuck

Our project has 300+ modules and we use gradle’s idea plugin for intellij configuration.

“gradle idea” build is not working after upgrading to 8.5 version (It’s currently working with gradle v7.2 ), the build is always stuck and doesn’t contain any error/failure information in debug logs, unable to produce scan report since the build is never complete.
We tried using --no-parallel, -Dorg.gradle.parallel=false, --no-daemon and -Dorg.gradle.workers.max=1 etc, but nothing worked. We even tried with latest versions of gradle(tried upto v8.12), but still seeing the same issue.

Understood that ideaModule target of idea task is running parallelly on modules and ending deadlock situation. So tried running ideaModule sequentially with below code and few others ways, but nothing worked for us.

idea {
    module {
        beforeEvaluate {
            // Create a list of all the modules
            def modules = project.idea.module.modules
            // Sort the modules in the order you want them to be processed
            modules.sort { it.name }
            // Iterate over the sorted modules and set the dependencies
            for (int i = 0; i < modules.size(); i++) {
                def module = modules[i]
                // Set the dependency for the current module
                if (i > 0) {
                    module.dependsOn modules[i - 1]
                }
            }
        } ......//exclude few dirs code
    }
}

I request you to check what is breaking it from working after 8.5 versions of gradle, this issue is blocking our delivery.

Java Version : Temurin-21.0.5+11-LTS

Please let me know if anymore information is needed.

I’m unable to attach threaddump here.

this issue is blocking our delivery

If this is something you need urgent help with, you might consider hiring some expert Gradle consultant which you can also give access to your project to investigate the issue.
This is “just” a community forum where users like me help other users in their spare time.

Short of that, can you knit and provide some MCVE that reproduces the issue you are seeing?