Importing Gradle project into IntelliJ fails to configure the .ipr file

The following build script was derived from geb’s geb/gradle/idea.gradle file:

apply plugin: 'idea'
  idea {
 project {
  jdkName "1.7"
  ipr {
   withXml { provider ->
    def node = provider.asNode()
    node.component.find { it.'@name' == 'VcsDirectoryMappings' }?.mapping[0].'@vcs' = 'Git'
    // ...

I noticed that if I use the idea task in the Gradle GUI, then the component element named VcsDirectoryMappings is properly configured. However, if I import the project into IntelliJ it doesn’t configure the ipr file.

That’s expected. Direct XML configuration only works with the ‘idea’ task, not with the IDE import.