Generated Idea project file includes modules which are disabled

When generating the Intellij Idea project file it includes all modules even if the ideaModule.enabled is set to false. To get around this I have added the following code to my gradle build file.

gradle.projectsEvaluated {

gradle.rootProject {

ideaModule.enabled = false

idea {

project {

modulesToInclude = subprojects.findAll {it.ideaModule.enabled == true}

modules = modulesToInclude.idea.module



} }