In Maven, the dependencies of a project is specified in the pom.xml file. In IntelliJ IDEA, the same information is stored in an iml file even for Maven projects. What is the need for having the same infromation in two places?
IML file stores information concerning development modules like an android, plugin, java, or maven component of a java application. It stores modules, paths, types, dependencies, and order settings. Additionally, it stores a module-level setting for larger development projects while using XML formatting.
A module file (the . iml file) is used for keeping module configuration. Modules allow you to combine several technologies and frameworks in one application. In IntelliJ IDEA, you can create several modules for a project and each of them can be responsible for its own framework.
When importing Maven project IDEA represents its dependencies model in the format that it can understand and use internally. If you manage dependencies via Maven, you don't need to change the dependencies in the IntelliJ IDEA module setting.
This can be also used to experiment with dependencies without changing the pom.xml
. Note that all the modifications you make will be reverted on next Maven import.
In other words, IDEA doesn't understand Maven model directly, it converts it to its own project model used by all the subsystems, and the internal project information needs to be stored somewhere, hence the .iml
files and .idea
project directory. This way IDEA doesn't need to analyze the pom file every time you open the project and resolve all the dependencies again, it's done only when the pom.xml
changes.
As you can build/run/test/deploy/debug Maven projects in IDEA without using Maven at all, the information needed for these tasks is stored in the format that IDE can understand itself. It's faster, easier to maintain and I guess was easier to implement than reading Maven model directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With