Idea plugin: iml.withXml not applied if project imported from gradle

I defined a build.gradle file with contents similar to that described in

I can see the expected changes to the .iml file if I run

gradle idea

However, if I import the project into IntelliJ from the gradle file, I do not see these changes. When importing, I do see the effects of changes to idea.module.sourceDirs, so I know my build.gradle file is being processed in some way. Is there a way I can get changes to idea.module.iml.withXml to also apply?

‘withXml’ only works together with ‘gradle idea’. Most other ‘idea’ configuration is also honored by the IDE import.

Is there any other way to add a packagePrefix attribute to a sourceFolder tag in the .iml?

I’m not aware of any, but you can check for yourself in the Gradle Build Language Reference (see ‘IdeaModule’, ‘IdeaProject’, etc.).