IntellJ reimport Gradle Project and iml.withXml{}

Answered

Hi,

I am aware this is a known issue. When IJ reimports Gradle project, it skips iml.withXml{} callback. We have some custom withXml{} that further configures .iml module file and it would be nice to run the callback during import. Oddly, running "reimport" after "idea" task brings you back to square one, xml changes are wiped out. This workflow is confusing.

  1. What Gradle tasks does IJ actually run when reimporting?
  2. Is there a way to include iml.withXml{}? What else does it skip?
  3. Am I able to detect user clicked "reimport" versus user clicked Gradle "idea" task?

I noticed IJ is slow "detecting" .iml file changes. Is there API to force IJ to refresh from my build.gradle?

Thank you

 

1 comment
Comment actions Permalink

>Oddly, running "reimport" after "idea" task brings you back to square one, xml changes are wiped out. This workflow is confusing.

On each re-import IDE re-generates the iml files, this is expected behaviour.

>What Gradle tasks does IJ actually run when reimporting?

It does not run any particular Gradle tasks. It uses Gradle Tooling API for reading Gradle model based on build.gradle and configured IDE project accordingly.


See also https://youtrack.jetbrains.com/issue/IDEA-127013#focus=streamItem-27-1726264.0-0

There is gradle-idea-ext-plugin that allows to map some IDE-specific settings to build.gradle and use this information during import process for some IDE-specific configurations (like Run/Debug Configurations, Encoding settings etc). You can check related documentation to see what IDE settings are supported: https://github.com/JetBrains/gradle-idea-ext-plugin/wiki

0

Please sign in to leave a comment.