Search code examples
javaeclipsemavengithubm2eclipse

difference between building project using maven and eclipse export as Jar


This sounds like a dumb question but i am really confused with this. I never used maven but i know that it is used to build projects.

So, I have a question : why there is a need of building project using Maven when we can build project in Eclipse (without Maven). Just by exporting the eclipse project as JAR and include required Libraries and all.

suppose, I download any project from github. Now I can import that project in eclipse and export it as JAR and use it functionality. So why all suggest to use MAVEN to build project and generate binaries and use it.


Solution

  • First of all, not everybody uses Eclipse (even in the same team), and different IDEs could produce slightly different artifacts (JAR files).

    One advantage of Maven is that it does not only build projects:

    • it prones convention over configuration, and suggests a "standard" layout for projects
    • it allows gathering all the dependencies needed in your project, using specific versions (as opposed to having something like "lib/log4j.jar", no version is specified)
    • it allows making lots of different artifacts: JARs containing compiled code or source code, javadoc, WARs, etc.
    • it can be run outside of your IDE, very often on a continuous integration server

    I would recommend using Maven even for small projects :)