What is Maven for?


I often find large projects that have the pom.xml file, but I never understood the utility of it, I just discovered that it is something related to maven. Anyway:

  • What is Maven for?
  • What is the pom.xml file for?
asked by anonymous 20.04.2015 / 05:19

1 answer


Maven is a tool developed by Apache, it serves to manage dependencies and automate your builds .

pom.xml is the Maven configuration file.

Managing dependencies

It is very common to find projects that make use of other libraries or frameworks, to use them it is necessary to access them through the dependencies. Dependencies in Java are compressed files and stored with the .jar extension. Some of these dependencies have one or more subdependencies and some of them have one or more sub-dependencies, and so on. Instead of when you need a dependency you go search for it on Google, download it, add it to your project and find out that it needs X new subdependencies and stay in a giant dependency hunting cycle, you can automate this process < strike> annoying and tiresome, and focus on the development that really gives value to your project.

Maven automates this for you!

There is a repository that is considered central to Maven that can be accessed through this link: link . In addition there are many other repository scattered around, and a good way to find them is through the link site that indexes other repositories and provides a way more friendly look for the dependencies you need.

When searching for a dependency to be accessed through Maven you will get an XML snippet that serves to set up the pom.xml of your project and indicate that you are making use of this dependency in your project. By adding this snippet, Maven downloads it and stores it in a local repository on your computer, if you have more than one project making use of the same dependency you will only have a single file on your computer in your local repository organized by Maven .

Another great advantage of dependency being in a local repository, not in your project folder, is that when using versioning tools such as GIT you will not need to add your% s to% s in it, since the responsibility of managing the dependencies is no longer yours, but rather of Maven.

An example of an XML snippet that sets up Maven to use a dependency:


Automating builds

You can automate tasks in your project that can be generated with% executable files by making appropriate use of the dependencies or even deploy web . / p>

For example: Build build in the Maven project and Creating JAR with dependencies in Maven

20.04.2015 / 05:55