Consistency when renaming IntelliJ modules imported from Maven
Hi,
I'm trying to figure out the intended workflow for renaming of IntelliJ modules and Maven projects.
We use Maven multi-modules to organize our code base, with a top-level multi-module that transitively aggregates all of our other Maven projects. This top-level multi-module gets imported into IntelliJ using File | Project Structure... | Project Settings | Modules | + | Import Module, which also imports all aggregated Maven projects. This initial import works quite well and IntelliJ creates IntelliJ modules for every Maven project it encounters, naming the modules after the artifactId in their POMs. Of course we share all the POMs through our VCS, but not the *.iml files IntelliJ creates during the import, so each developer has her own local set of *.iml files created by the respective import run.
We frequently rename Maven projects during refactorings by changing the artifactId of such projects and here the problems start. At least the Maven subsystem of IntelliJ realizes that some POMs haven been changed and reloads the Maven projects, so their updated names can be seen in the Maven view. Unfortunately these changes do not affect the names of the IntelliJ modules which are shown, e.g., in the Project view.
So when developer A makes such a refactoring, commits her changes (the updates POMs) to the VCS, and developer B updates her local working copy with these changes, IntelliJ of developer B still shows the old module names in the Project view. Even if developer A also performs a refactoring on the IntelliJ module names, such changes are only local to developer A. This introduces inconsistencies und confusion during daily work and I am really stunned that this state still prevails with IntelliJ 2020.2.1.
So, what is the intended way to rename Maven projects and IntelliJ modules and consistently share these refactorings with other developers through the VCS?
How do I even perform a complete and clean re-import of all Maven projects? Reload All Maven Projects in the Maven view just triggers some update mechanism, as it leaves manual changes to, e.g., module dependencies untouched.
Regards,
Alex
Please sign in to leave a comment.
It's an old bug, please follow https://youtrack.jetbrains.com/issue/IDEA-26914 for updates. See https://intellij-support.jetbrains.com/hc/articles/207241135 if you are not familiar with YouTrack.
Thanks for the hint, Serge. I upvoted the issue you mentioned but it's somewhat disappointing to see issues like this one or even like https://youtrack.jetbrains.com/issue/IDEA-94223 with over 20 votes lie dormant for 8 to 11 years.
Also, my second question remains unanswered: How do I re-import already imported IntelliJ modules from Maven so that their initial configurations, which are derived from the respective Maven projects, is restored? When you manually change dependencies of a module through File | Project Structure... | Project Settings | Modules, IntelliJ warns you with "Module 'x.y.z' is imported from Maven. Any changes made in its configuration may be lost after reimporting.", but I could not find how to perform the mentioned "reimporting".
It should work using reimport action per https://stackoverflow.com/a/43192764/104891. If it doesn't work, it's also a bug.
The auto-reload functionality of the Maven subsystem doesn't completely reset the configurations of the corresponding IntelliJ modules, e.g., it does not remove manually added dependencies to a module, it also does not change the module name according to the artifactId of the Maven project. The behavior to leave manually added dependencies alone is OK for us, we even need it that way. The issue regarding the module naming we've already discussed.
Meanwhile, I figured out how to really re-import a Maven project:
This way IntelliJ completely rebuilds the module configuration from the Maven configuration, module dependencies are reset and even the module name gets re-evaluated from the artifactId. However, regarding regular refactorings of artifactId, this is not a viable option.