If I add a dependency by entering it in pom.xml, it is added as a "java library" in project structure > libraries. This uses Maven to add the library. Right?
However, in project structure > libraries, there is an option to add Maven projects, but these are not added to pom.xml and appear as maven libraries as opposed to java libraries in the project view. Why? What's the difference?
It's certainly convenient to use new library > from maven because you can search for libraries. However, the libraries not being added to pom.xml seems like a drawback because this way some libraries will be in pom.xml and others not.
Could someone explain how all this works?
About Maven - its primary goal is to support development with stable state of. In order to attain this goal there are several areas of concern that Maven attempts to deal with:
Project Object Model or POM is one of the most important units of work in Maven. As you already know it's an XML file that contains information about the project and configuration details used by Maven to build the project. So yes - If you add .jar as dependency in both POM and Project structure it'll automatically create such in VCS too.
Based on my experience with IntelliJ Idea it's very important to remember to add this new .jar in Subversion too (Right click on .jar > Subversion > Add). A couple of times ItelliJ Idea set it as local change and actually you don't commit this file - and believe me it's very annoying to deal with it. Maybe the most important thing about POM is that it helps with avoiding so called 'Jar hell'. In POM you set goals, so when executing a task or goal, Maven looks for the POM in the current directory. It reads the POM, gets the needed configuration information, then executes the goal.
Also as a tip - when updating POM and Maven I prefer to use the FileSystem and cmd. By doing so I've managed to avoid not one-or-two IntelliJ 'misreadings'. Very helpful are also the "Lifecycle" commands. e.g. clean
/verify
/install
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