Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA + Maven what is the need for dependency entries in an iml file?

Tags:

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?

like image 885
Can't Tell Avatar asked Apr 04 '12 03:04

Can't Tell


People also ask

What is the use of IML file in Maven project?

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.

What is the use of IML file in IntelliJ?

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.


1 Answers

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.

like image 104
CrazyCoder Avatar answered Nov 09 '22 00:11

CrazyCoder