Can anyone explain how IntelliJ, Maven and pom.xml work?

If I add a dependency by injecting it in the pom.xml it is added as "java library" in the project structure> libraries. This is using Maven to add the library. Right?

However, in the project structure> libraries, it is possible to add Maven projects, but they are not added to the pom.xml and appear as maven libraries, not java libraries in the project view. What for? Who cares?

It is of course convenient to use the new library> from maven because you can search for libraries. However, libraries not being added to the pom.xml seem like drawbacks because this way some libraries will be in the pom.xml and others won't.

Can someone explain how it all works?

+3


source to share


1 answer


About Maven - Its main goal is to keep development in a stable state. To achieve this goal, there are several problems that Maven is trying to deal with:

  • Allow transparent migration to new features
  • Providing a unified build system
  • Easy creation of build process
  • Providing quality information about the project

The Project Object Model, or POM, is one of the most important units of work in Maven. As you already know this is an XML file containing information about the project and configuration details that Maven uses to create the project. So yes. If you add the .jar as a dependency in both the POM structure and Project, it will automatically create that capability in the VCS.



Based on my experience with IntelliJ Idea, it's very important to remember to add this new .jar to Subversion too (right click on .jar> Subversion> Add). A couple of times ItelliJ Idea installed it as a local change and you are not actually committing that file and believe me, I am very uncomfortable dealing with it. Perhaps the most important thing about POM is that it avoids the so-called "Jar hell". In the POM, you set goals, so when you execute a task or target, Maven looks for the POM in the current directory. It reads the POM, gets the required configuration information, and then executes the target.

Also as a hint - when updating POM and Maven, I prefer to use FileSystem and cmd. By doing so, I have been able to avoid a few IntelliJ "misinterpretations". The "Lifecycle" commands are also very useful. eg clean

/ verify

/install

+1


source







All Articles