How can I get IDE imports to trigger taskGraph.whenReady?

My plugin applies some dependency forces in a taskGraph.whenReady block

project.gradle.taskGraph.whenReady { taskGraph ->
  if (!taskGraph.hasTask(generateLock)) {

Importing projects using this plugin into IntelliJ or Eclipse using the IDE’s import functionality does not trigger this block. Is there a way to cause taskGraph.whenReady to trigger or do I need to figure out a way to capture the initial forces, lock in an afterEvaluate, and somehow replace the initial forces if the generateLock task is present?

You might have to hook into the IDEA plugin DSL within your plugin. For example when the project files are generated then do something beforehand:

idea.project.ipr {
    beforeMerged { project ->
        // your logic here