Do you mean that opening build.gradle with IntelliJ IDEA doesn’t generate an iml file as you wish?
If so, I think this problem is not Gradle’s, but IntelliJ IDEA’s. It seems that IntelliJ IDEA generates an iml file by itself and doesn’t see idea{} block.
My solution is…
Run idea task.
Import project via the ipr file generated by Gradle.
Ignore all suggestions on Gradle from IntelliJ IDEA.
or
Import Gradle project with IntelliJ IDEA.
Run idea task and override iml file.
Reopen the project prompted by IntelliJ IDEA
Ignore all suggestions on Gradle from IntelliJ IDEA after reopening project.
The idea{} block is executed, but not the inner withXml block. I’m inclined to believe this is an IntelliJ issue.
Thanks for the suggested solutions, but in my case I’m using android studio and our build.gradle files change often. So it is very convenient to update the source tree and “automagicaly” recreate .iml files when it changes instead of manually recreate it.
Hi @rdtorres, I am having the same problem as you. I am trying to modify one module’s .iml file and the withXml closure does not execute. Did you ever figure out why?
Here’s a simple version of my use case:
idea.module {
scopes.TEST.plus += [configurations.myCustomConfiguration] //this works and adds directories to module deps
iml {
withXml {
//append some node here... but never executes
}
}
}
I am using IJ 2017.2.5 (Build #IC-172.4343.14) and Gradle 4.3-rc-1.