Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
334 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...